Search code examples
djangosettingsdjango-haystackelasticsearch

Add index settings to elastic search


How do I add index settings to haystack with elastic backend, like this guy has added in the question?

django-haystack autocomplete returns too wide results

My ngram search is returning all the docs. When I rebuild my index the mapping is automatically taken from the model.


Solution

  • I found an answer. This link can help in creating custom elastic search settings : https://wellfire.co/learn/custom-haystack-elasticsearch-backend/

    You have to inherit ElasticsearchSearchBackend to make a new CustomElasticsearchBackend and set the custom elasticsearch settings dict in the init of that class.

    There can be a lot more that can be done using the same idea. Like making the build_schema function to work differently. Also the Fields of haystack like CharField, NgramField, EdgeNgramField can be inherited to make custom fields to work for you.