index analyzer vs query analyzer in haystack - elasticsearch?

独自空忆成欢 提交于 2019-12-11 07:58:50

问题


Elasticsearch itself seems to support index-analyzer and query-analyzer,
but haystack's elasticsearch doesn't seem to differentiate them.

Am I Correct?

related question is,

Elasticsearch's DEFAULT_SETTING seems to have 'settings.analysis.anaylyzer' and 'index.analysys.anaylyzer'. (eg. http://www.wellfireinteractive.com/blog/custom-haystack-elasticsearch-backend/ has 'index') What's the difference between them?


回答1:


With haystack, you want to set the mappings yourself.

I wrote about haystack as well earlier here: Django Haystack Distinct Value for Field

In the settings, you can define analyzers on a per field basis, they can be a default analyzer (which is what haystack defaults to and get's applied at both search and index time) a search time analyzer and a query time analyzer.

It's usually good practice to define both a search time analyzer and index time analyzer, even if they are the exact same.

Using snowball text analyses, you might want to apply this at both search and index time, but something like an autocomplete feature, you might not want that (which is what haystack does). You want the index analyzer to store (edge)ngrams and usually you want to apply a stricter search time analysis, like keyword.

You almost never want to let haystack define the mapping.

As for the second part, see here: http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/indices-create-index.html

Mid way down it says:

"Note you do not have to explicitly specify index section inside settings section."

I just tried this myself as well, because I had never tested it.



来源:https://stackoverflow.com/questions/20212078/index-analyzer-vs-query-analyzer-in-haystack-elasticsearch

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!