简体   繁体   中英

index analyzer vs query analyzer in haystack - elasticsearch?

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM