Skip to content Skip to sidebar Skip to footer

Elasticsearch-dsl-py Sorting By Text() Field

I have problem with .sort() method. For example I have Index with Text() field: FILTER = token_filter( 'FILTER', 'edge_ngram', min_gram=3, max_gram=40) ANALYZER = analyzer(

Solution 1:

You cannot sort on a text field, that is a limitation in elasticsearch. It needs to be a type keyword.

Unfortunately type keyword cannot have an analyzer, it can, however, have a normalizer which performs similar, albeit a bit limited, function. Essentially the difference is that you cannot specify a tokenizer since then any sorting would not make much sense (which token would you use for sorting when you have multiple?)

hope this helps

Post a Comment for "Elasticsearch-dsl-py Sorting By Text() Field"