Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 882a727

Browse files
committed
[ckan#1314] Single Solr schema file
To make easier to track changes and simplify the deplyment and upgrade, the Solr schema file included in the CKAN source is now unified under `schema.xml`. As part of the release process, the file will be checked for changes, and if present the version numbers on the schema file and the supported versions list will be updated. Release, install and upgrade docs have been updated to reflect this changes. Travis now also always points to schema.xml
1 parent 91f3184 commit 882a727

15 files changed

Lines changed: 237 additions & 115 deletions

CHANGELOG.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@ v2.2
1212

1313
API changes and deprecations:
1414

15-
15+
* The Solr schema file is now always named ``schema.xml`` regardless of the
16+
CKAN version. Old schema files have been kept for backwards compatibility
17+
but users are encouraged to point to the new unified one.
1618
* The `ckan.api_url` has been completely removed and it can no longer be used
1719
* The edit() and after_update() methods of IPackageController plugins are now
1820
called when updating a resource using the web frontend or the

bin/travis-run-tests

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22

33
# Configure Solr
44
echo "NO_START=0\nJETTY_HOST=127.0.0.1\nJETTY_PORT=8983\nJAVA_HOME=$JAVA_HOME" | sudo tee /etc/default/jetty
5-
# FIXME the solr schema cannot be hardcoded as it is dependent on the ckan version
6-
sudo cp ckan/config/solr/schema-2.0.xml /etc/solr/conf/schema.xml
5+
sudo cp ckan/config/solr/schema.xml /etc/solr/conf/schema.xml
76
sudo service jetty restart
87

98
# Run mocha front-end tests

ckan/config/solr/CHANGELOG.txt

Lines changed: 0 additions & 29 deletions
This file was deleted.

ckan/config/solr/README.txt

Lines changed: 9 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,12 @@
1-
CKAN SOLR schemas
2-
=================
1+
CKAN Solr schema
2+
================
33

4-
This folder contains the latest and previous versions of the SOLR XML
5-
schema files used by CKAN. These can be use on the SOLR server to
6-
override the default SOLR schema. Please note that not all schemas are
7-
backwards compatible with old CKAN versions. Check the CHANGELOG.txt file
8-
in this same folder to check which version of the schema should you use
9-
depending on the CKAN version you are using.
4+
This folder contains the Solr schema file used by CKAN (schema.xml).
105

11-
Developers, when pushing changes to the SOLR schema:
6+
Starting from 2.2 this is the only file that should be used by users and
7+
modified by devs. The rest of files (schema-{version}.xml) are kept for
8+
backwards compatibility purposes and should not be used, as they might be
9+
removed in future versions.
1210

13-
* Note that updates on the schema are only release based, i.e. all changes
14-
in the schema between releases will be part of the same new version of
15-
the schema.
16-
17-
* Name the new version of the file using the following convention::
18-
19-
schema-<version>.xml
20-
21-
* Update the `version` attribute of the `schema` tag in the new file::
22-
23-
<schema name="ckan" version="<version>">
24-
25-
* Update the SUPPORTED_SCHEMA_VERSIONS list in `ckan/lib/search/__init__.py`
26-
Consider if the changes introduced are or are not compatible with
27-
previous schema versions.
28-
29-
* Update the CHANGELOG.txt file with the new version, the CKAN version
30-
required and changes made to the schema.
11+
When upgrading CKAN, always check the CHANGELOG on each release to see if
12+
you need to update the schema file and reindex your datasets.

ckan/config/solr/schema-1.2.xml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
11
<?xml version="1.0" encoding="UTF-8" ?>
2+
<!--
3+
THIS FILE IS DEPRECATED
4+
Starting from CKAN 2.2 the Solr schema file that should be used is
5+
`schema.xml`.
6+
7+
This file is maintained for backwards compatibility purposes but might
8+
be removed in future vesions.
9+
-->
210
<!--
311
Licensed to the Apache Software Foundation (ASF) under one or more
412
contributor license agreements. See the NOTICE file distributed with

ckan/config/solr/schema-1.3.xml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
11
<?xml version="1.0" encoding="UTF-8" ?>
2+
<!--
3+
THIS FILE IS DEPRECATED
4+
Starting from CKAN 2.2 the Solr schema file that should be used is
5+
`schema.xml`.
6+
7+
This file is maintained for backwards compatibility purposes but might
8+
be removed in future vesions.
9+
-->
210
<!--
311
Licensed to the Apache Software Foundation (ASF) under one or more
412
contributor license agreements. See the NOTICE file distributed with

ckan/config/solr/schema-1.4.xml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
11
<?xml version="1.0" encoding="UTF-8" ?>
2+
<!--
3+
THIS FILE IS DEPRECATED
4+
Starting from CKAN 2.2 the Solr schema file that should be used is
5+
`schema.xml`.
6+
7+
This file is maintained for backwards compatibility purposes but might
8+
be removed in future vesions.
9+
-->
210
<!--
311
Licensed to the Apache Software Foundation (ASF) under one or more
412
contributor license agreements. See the NOTICE file distributed with

ckan/config/solr/schema-2.0.xml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
11
<?xml version="1.0" encoding="UTF-8" ?>
2+
<!--
3+
THIS FILE IS DEPRECATED
4+
Starting from CKAN 2.2 the Solr schema file that should be used is
5+
`schema.xml`.
6+
7+
This file is maintained for backwards compatibility purposes but might
8+
be removed in future vesions.
9+
-->
210
<!--
311
Licensed to the Apache Software Foundation (ASF) under one or more
412
contributor license agreements. See the NOTICE file distributed with

ckan/config/solr/schema.xml

Lines changed: 165 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,165 @@
1+
<?xml version="1.0" encoding="UTF-8" ?>
2+
<!--
3+
Licensed to the Apache Software Foundation (ASF) under one or more
4+
contributor license agreements. See the NOTICE file distributed with
5+
this work for additional information regarding copyright ownership.
6+
The ASF licenses this file to You under the Apache License, Version 2.0
7+
(the "License"); you may not use this file except in compliance with
8+
the License. You may obtain a copy of the License at
9+
10+
http://www.apache.org/licenses/LICENSE-2.0
11+
12+
Unless required by applicable law or agreed to in writing, software
13+
distributed under the License is distributed on an "AS IS" BASIS,
14+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
See the License for the specific language governing permissions and
16+
limitations under the License.
17+
-->
18+
19+
<schema name="ckan" version="2.0">
20+
21+
<types>
22+
<fieldType name="string" class="solr.StrField" sortMissingLast="true" omitNorms="true"/>
23+
<fieldType name="boolean" class="solr.BoolField" sortMissingLast="true" omitNorms="true"/>
24+
<fieldtype name="binary" class="solr.BinaryField"/>
25+
<fieldType name="int" class="solr.TrieIntField" precisionStep="0" omitNorms="true" positionIncrementGap="0"/>
26+
<fieldType name="float" class="solr.TrieFloatField" precisionStep="0" omitNorms="true" positionIncrementGap="0"/>
27+
<fieldType name="long" class="solr.TrieLongField" precisionStep="0" omitNorms="true" positionIncrementGap="0"/>
28+
<fieldType name="double" class="solr.TrieDoubleField" precisionStep="0" omitNorms="true" positionIncrementGap="0"/>
29+
<fieldType name="tint" class="solr.TrieIntField" precisionStep="8" omitNorms="true" positionIncrementGap="0"/>
30+
<fieldType name="tfloat" class="solr.TrieFloatField" precisionStep="8" omitNorms="true" positionIncrementGap="0"/>
31+
<fieldType name="tlong" class="solr.TrieLongField" precisionStep="8" omitNorms="true" positionIncrementGap="0"/>
32+
<fieldType name="tdouble" class="solr.TrieDoubleField" precisionStep="8" omitNorms="true" positionIncrementGap="0"/>
33+
<fieldType name="date" class="solr.TrieDateField" omitNorms="true" precisionStep="0" positionIncrementGap="0"/>
34+
<fieldType name="tdate" class="solr.TrieDateField" omitNorms="true" precisionStep="6" positionIncrementGap="0"/>
35+
36+
<fieldType name="text" class="solr.TextField" positionIncrementGap="100">
37+
<analyzer type="index">
38+
<tokenizer class="solr.WhitespaceTokenizerFactory"/>
39+
<filter class="solr.WordDelimiterFilterFactory" generateWordParts="1" generateNumberParts="1" catenateWords="1" catenateNumbers="1" catenateAll="0" splitOnCaseChange="1"/>
40+
<filter class="solr.LowerCaseFilterFactory"/>
41+
<filter class="solr.SnowballPorterFilterFactory" language="English" protected="protwords.txt"/>
42+
<filter class="solr.ASCIIFoldingFilterFactory"/>
43+
</analyzer>
44+
<analyzer type="query">
45+
<tokenizer class="solr.WhitespaceTokenizerFactory"/>
46+
<filter class="solr.SynonymFilterFactory" synonyms="synonyms.txt" ignoreCase="true" expand="true"/>
47+
<filter class="solr.WordDelimiterFilterFactory" generateWordParts="1" generateNumberParts="1" catenateWords="0" catenateNumbers="0" catenateAll="0" splitOnCaseChange="1"/>
48+
<filter class="solr.LowerCaseFilterFactory"/>
49+
<filter class="solr.SnowballPorterFilterFactory" language="English" protected="protwords.txt"/>
50+
<filter class="solr.ASCIIFoldingFilterFactory"/>
51+
</analyzer>
52+
</fieldType>
53+
54+
55+
<!-- A general unstemmed text field - good if one does not know the language of the field -->
56+
<fieldType name="textgen" class="solr.TextField" positionIncrementGap="100">
57+
<analyzer type="index">
58+
<tokenizer class="solr.WhitespaceTokenizerFactory"/>
59+
<filter class="solr.WordDelimiterFilterFactory" generateWordParts="1" generateNumberParts="1" catenateWords="1" catenateNumbers="1" catenateAll="0" splitOnCaseChange="0"/>
60+
<filter class="solr.LowerCaseFilterFactory"/>
61+
</analyzer>
62+
<analyzer type="query">
63+
<tokenizer class="solr.WhitespaceTokenizerFactory"/>
64+
<filter class="solr.SynonymFilterFactory" synonyms="synonyms.txt" ignoreCase="true" expand="true"/>
65+
<filter class="solr.WordDelimiterFilterFactory" generateWordParts="1" generateNumberParts="1" catenateWords="0" catenateNumbers="0" catenateAll="0" splitOnCaseChange="0"/>
66+
<filter class="solr.LowerCaseFilterFactory"/>
67+
</analyzer>
68+
</fieldType>
69+
</types>
70+
71+
72+
<fields>
73+
<field name="index_id" type="string" indexed="true" stored="true" required="true" />
74+
<field name="id" type="string" indexed="true" stored="true" required="true" />
75+
<field name="site_id" type="string" indexed="true" stored="true" required="true" />
76+
<field name="title" type="text" indexed="true" stored="true" />
77+
<field name="entity_type" type="string" indexed="true" stored="true" omitNorms="true" />
78+
<field name="dataset_type" type="string" indexed="true" stored="true" />
79+
<field name="state" type="string" indexed="true" stored="true" omitNorms="true" />
80+
<field name="name" type="string" indexed="true" stored="true" omitNorms="true" />
81+
<field name="revision_id" type="string" indexed="true" stored="true" omitNorms="true" />
82+
<field name="version" type="string" indexed="true" stored="true" />
83+
<field name="url" type="string" indexed="true" stored="true" omitNorms="true" />
84+
<field name="ckan_url" type="string" indexed="true" stored="true" omitNorms="true" />
85+
<field name="download_url" type="string" indexed="true" stored="true" omitNorms="true" />
86+
<field name="notes" type="text" indexed="true" stored="true"/>
87+
<field name="author" type="textgen" indexed="true" stored="true" />
88+
<field name="author_email" type="textgen" indexed="true" stored="true" />
89+
<field name="maintainer" type="textgen" indexed="true" stored="true" />
90+
<field name="maintainer_email" type="textgen" indexed="true" stored="true" />
91+
<field name="license" type="string" indexed="true" stored="true" />
92+
<field name="license_id" type="string" indexed="true" stored="true" />
93+
<field name="ratings_count" type="int" indexed="true" stored="false" />
94+
<field name="ratings_average" type="float" indexed="true" stored="false" />
95+
<field name="tags" type="string" indexed="true" stored="true" multiValued="true"/>
96+
<field name="groups" type="string" indexed="true" stored="true" multiValued="true"/>
97+
98+
<field name="capacity" type="string" indexed="true" stored="true" multiValued="false"/>
99+
100+
<field name="res_description" type="textgen" indexed="true" stored="true" multiValued="true"/>
101+
<field name="res_format" type="string" indexed="true" stored="true" multiValued="true"/>
102+
<field name="res_url" type="string" indexed="true" stored="true" multiValued="true"/>
103+
104+
<!-- catchall field, containing all other searchable text fields (implemented
105+
via copyField further on in this schema -->
106+
<field name="text" type="text" indexed="true" stored="false" multiValued="true"/>
107+
<field name="urls" type="text" indexed="true" stored="false" multiValued="true"/>
108+
109+
<field name="depends_on" type="text" indexed="true" stored="false" multiValued="true"/>
110+
<field name="dependency_of" type="text" indexed="true" stored="false" multiValued="true"/>
111+
<field name="derives_from" type="text" indexed="true" stored="false" multiValued="true"/>
112+
<field name="has_derivation" type="text" indexed="true" stored="false" multiValued="true"/>
113+
<field name="links_to" type="text" indexed="true" stored="false" multiValued="true"/>
114+
<field name="linked_from" type="text" indexed="true" stored="false" multiValued="true"/>
115+
<field name="child_of" type="text" indexed="true" stored="false" multiValued="true"/>
116+
<field name="parent_of" type="text" indexed="true" stored="false" multiValued="true"/>
117+
<field name="views_total" type="int" indexed="true" stored="false"/>
118+
<field name="views_recent" type="int" indexed="true" stored="false"/>
119+
<field name="resources_accessed_total" type="int" indexed="true" stored="false"/>
120+
<field name="resources_accessed_recent" type="int" indexed="true" stored="false"/>
121+
122+
<field name="metadata_created" type="date" indexed="true" stored="true" multiValued="false"/>
123+
<field name="metadata_modified" type="date" indexed="true" stored="true" multiValued="false"/>
124+
125+
<field name="indexed_ts" type="date" indexed="true" stored="true" default="NOW" multiValued="false"/>
126+
127+
<!-- Copy the title field into titleString, and treat as a string
128+
(rather than text type). This allows us to sort on the titleString -->
129+
<field name="title_string" type="string" indexed="true" stored="false" />
130+
131+
<field name="data_dict" type="string" indexed="false" stored="true" />
132+
<field name="validated_data_dict" type="string" indexed="false" stored="true" />
133+
134+
<field name="_version_" type="string" indexed="true" stored="true"/>
135+
136+
<dynamicField name="*_date" type="date" indexed="true" stored="true" multiValued="false"/>
137+
138+
<dynamicField name="extras_*" type="text" indexed="true" stored="true" multiValued="false"/>
139+
<dynamicField name="vocab_*" type="string" indexed="true" stored="true" multiValued="true"/>
140+
<dynamicField name="*" type="string" indexed="true" stored="false"/>
141+
</fields>
142+
143+
<uniqueKey>index_id</uniqueKey>
144+
<defaultSearchField>text</defaultSearchField>
145+
<solrQueryParser defaultOperator="AND"/>
146+
147+
<copyField source="url" dest="urls"/>
148+
<copyField source="ckan_url" dest="urls"/>
149+
<copyField source="download_url" dest="urls"/>
150+
<copyField source="res_url" dest="urls"/>
151+
<copyField source="extras_*" dest="text"/>
152+
<copyField source="vocab_*" dest="text"/>
153+
<copyField source="urls" dest="text"/>
154+
<copyField source="name" dest="text"/>
155+
<copyField source="title" dest="text"/>
156+
<copyField source="text" dest="text"/>
157+
<copyField source="license" dest="text"/>
158+
<copyField source="notes" dest="text"/>
159+
<copyField source="tags" dest="text"/>
160+
<copyField source="groups" dest="text"/>
161+
<copyField source="res_description" dest="text"/>
162+
<copyField source="maintainer" dest="text"/>
163+
<copyField source="author" dest="text"/>
164+
165+
</schema>

ckan/tests/lib/test_solr_schema_version.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import os
2-
from pylons import config
32
from ckan.tests import TestController
43

54
class TestSolrSchemaVersionCheck(TestController):
@@ -11,11 +10,7 @@ def setup_class(cls):
1110

1211
def _get_current_schema(self):
1312

14-
from ckan.lib.search import SUPPORTED_SCHEMA_VERSIONS
15-
16-
current_version = sorted(SUPPORTED_SCHEMA_VERSIONS).pop()
17-
18-
current_schema = os.path.join(self.root_dir,'..','..','config','solr','schema-%s.xml' % current_version)
13+
current_schema = os.path.join(self.root_dir,'..','..','config','solr','schema.xml')
1914

2015
return current_schema
2116

0 commit comments

Comments
 (0)