Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>What you need to do is override the search mapping in Haystack's ElasticSearch backend.</p> <p>In brief: extend the ElasticSearch backend and either replace directly or by a <code>settings.py</code> import a new schema mapping.</p> <pre><code>from django.conf import settings from haystack.backends.elasticsearch_backend import (ElasticsearchSearchBackend, ElasticsearchSearchEngine) class MyElasticBackend(ElasticsearchSearchBackend): def __init__(self, connection_alias, **connection_options): super(ConfigurableElasticBackend, self).__init__( connection_alias, **connection_options) MY_SETTINGS = { 'settings': { "analysis": { "analyzer": { "ngram_analyzer": { "type": "custom", "tokenizer": "lowercase", "filter": ["haystack_ngram"] }, "edgengram_analyzer": { "type": "custom", "tokenizer": "lowercase", "filter": ["haystack_edgengram"] } }, "tokenizer": { "haystack_ngram_tokenizer": { "type": "nGram", "min_gram": 3, "max_gram": 15, }, "haystack_edgengram_tokenizer": { "type": "edgeNGram", "min_gram": 2, "max_gram": 15, "side": "front" } }, "filter": { "haystack_ngram": { "type": "nGram", "min_gram": 3, "max_gram": 15 }, "haystack_edgengram": { "type": "edgeNGram", "min_gram": 5, "max_gram": 15 } } } } } setattr(self, 'DEFAULT_SETTINGS', MY_SETTINGS) class ConfigurableElasticSearchEngine(ElasticsearchSearchEngine): backend = MyElasticBackend </code></pre> <p>For a fuller explanation see my <a href="http://www.wellfireinteractive.com/blog/custom-haystack-elasticsearch-backend/" rel="noreferrer">write up about extending the ElasticSearch backend</a> to customize the search mapping.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload