Skip to content

Commit

Permalink
[#1905] Allow search on resource name field.
Browse files Browse the repository at this point in the history
Currently a package search will not search on the resource name field. With this change resource names are indexed so that package search will return dataset(s) where user searches for a resource by name.
  • Loading branch information
george committed Nov 8, 2014
1 parent 808bc49 commit 96c1d9d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
4 changes: 3 additions & 1 deletion ckan/config/solr/schema.xml
Expand Up @@ -97,6 +97,7 @@

<field name="capacity" type="string" indexed="true" stored="true" multiValued="false"/>

<field name="res_name" type="textgen" indexed="true" stored="true" multiValued="true" />
<field name="res_description" type="textgen" indexed="true" stored="true" multiValued="true"/>
<field name="res_format" type="string" indexed="true" stored="true" multiValued="true"/>
<field name="res_url" type="string" indexed="true" stored="true" multiValued="true"/>
Expand Down Expand Up @@ -161,8 +162,9 @@
<copyField source="notes" dest="text"/>
<copyField source="tags" dest="text"/>
<copyField source="groups" dest="text"/>
<copyField source="res_name" dest="text"/>
<copyField source="res_description" dest="text"/>
<copyField source="maintainer" dest="text"/>
<copyField source="author" dest="text"/>

</schema>
</schema>
7 changes: 4 additions & 3 deletions ckan/lib/search/index.py
Expand Up @@ -28,7 +28,7 @@
PACKAGE_TYPE = "package"
KEY_CHARS = string.digits + string.letters + "_-"
SOLR_FIELDS = [TYPE_FIELD, "res_url", "text", "urls", "indexed_ts", "site_id"]
RESERVED_FIELDS = SOLR_FIELDS + ["tags", "groups", "res_description",
RESERVED_FIELDS = SOLR_FIELDS + ["tags", "groups", "res_name", "res_description",
"res_format", "res_url", "res_type"]
RELATIONSHIP_TYPES = PackageRelationship.types

Expand Down Expand Up @@ -185,7 +185,8 @@ def index_package(self, pkg_dict, defer_commit=False):
pkg_dict['views_total'] = tracking_summary['total']
pkg_dict['views_recent'] = tracking_summary['recent']

resource_fields = [('description', 'res_description'),
resource_fields = [('name', 'res_name'),
('description', 'res_description'),
('format', 'res_format'),
('url', 'res_url'),
('resource_type', 'res_type')]
Expand Down Expand Up @@ -317,4 +318,4 @@ def delete_package(self, pkg_dict):
log.exception(e)
raise SearchIndexError(e)
finally:
conn.close()
conn.close()

0 comments on commit 96c1d9d

Please sign in to comment.