Installation:
1. Install the extension:
pip install ckanext-search-tweaks
2. Add plugins to ckan.plugins (at least search_tweaks required):
ckan.plugins = … search_tweaks [search_tweaks_query_relevance] [search_tweaks_field_relevance] [search_tweaks_spellcheck]
#
Plugin Descriptions:
- search_tweaks: Base plugin (required), switches to edismax, provides ISearchTweaks interface
- search_tweaks_query_relevance: Promotes datasets by visit frequency (requires Redis)
- search_tweaks_field_relevance: Boosts by numeric field value via Solr functions
- search_tweaks_spellcheck: ‘Did you mean?’ feature (requires Solr config changes)
#
Common Configuration (search_tweaks):
ckanext.search_tweaks.common.qf - Rewrite qf parameter (default: QUERY_FIELDS)
ckanext.search_tweaks.common.fuzzy_search.enabled - Enable fuzzy search (default: false)
ckanext.search_tweaks.common.fuzzy_search.distance - Max misspelled letters 1-2 (default: 1)
ckanext.search_tweaks.common.fuzzy_search.keep_original - Keep original in fuzzy (default: true)
ckanext.search_tweaks.common.prefer_boost - Use boost over bf with edismax (default: true)
ckanext.search_tweaks.common.mm - MinimumShouldMatch (default: 1)
#
Query Relevance Configuration:
ckanext.search_tweaks.query_relevance.min_boost - Minimum boost (default: 1)
ckanext.search_tweaks.query_relevance.max_boost - Maximum boost (default: 1.5)
ckanext.search_tweaks.query_relevance.max_boost_count - Max boosted datasets (default: 60)
#
Field Relevance Configuration:
ckanext.search_tweaks.field_relevance.boost_function - Solr boost function (e.g. pow(promoted_level,2))
ckanext.search_tweaks.field_relevance.blueprint.promotion.field_name - Promotion field name (default: promotion_level)
ckanext.search_tweaks.field_relevance.blueprint.promotion.enabled - Enable promotion route (default: False)
#
Spellcheck Configuration:
ckanext.search_tweaks.spellcheck.more_results_only - Only suggest if more results (default: true)
ckanext.search_tweaks.spellcheck.max_suggestions - Max suggestions count (default: 1)
#
CLI Commands:
ckan search-tweaks relevance query export/import/reset
ckan search-tweaks spellcheck rebuild
#
Spellcheck Solr Setup (solrconfig.xml):
Add to searchComponent:
did_you_mean
did_you_mean
false
Add to search handler:
spellcheck
Define schema field and copyFields from title, notes, res_name, etc.