search - elasticsearch query issue with ngram -
i have data in index
https://gist.github.com/bitgandtter/6794d9b48ae914a3ac7c
if notice in mapping im using ngram 3 tokens 20.
when execute query:
get /my_index/user/_search?search_type=dfs_query_then_fetch { "query": { "filtered": { "query":{ "multi_match":{ "query": "f", "fields": ["username","firstname","middlename","lastname"], "analyzer": "custom_search_analyzer" } } } } }
i should 8 documents have indexed 6 leaving out 2 names franz , francis. expect have 2 because f included in data. reason not working.
when execute:
get /my_index/user/_search?search_type=dfs_query_then_fetch { "query": { "filtered": { "query":{ "multi_match":{ "query": "fran", "fields": ["username","firstname","middlename","lastname"], "analyzer": "custom_search_analyzer" } } } } }
i 2 documents.
if lower ngram start @ 1 documents think affect performance of query.
what im missing here. in advance.
note: examples coded used sense
this expected since min_gram specified 3 mean minimum length of token produced custom analyzer 3 codepoints.
hence first token "franz silva" "fra". hence token "f" not match on document.
one can test out tokens produced analyzer using :
curl -xget "http://<server>/index_name/_analyze?analyzer=custom_analyzer&text=franz silva"
also note since "custom_analyzer" specified above not specify "token_chars", tokens can contain spaces.
Comments
Post a Comment