NGRAM Tokens and query_string question

If i have a field that is NGRAM tokenized and i do a query_string query does the search RANK the full word match over partial matches?

Example:

i search "test"
and i get the following docs:

my test document
my testing document
my tested document

test is matched to all 3 but will the first "my test document" be RANKED (scored) higher than the others since its a full word match?

Thanks,

test is matched to all 3 but will the first "my test document" be RANKED (scored) higher than the others since its a full word match?

No, if you want that, I would recommend that you analyze the text multiple ways by using a multi field (see: https://www.elastic.co/guide/en/elasticsearch/reference/5.3/multi-fields.html) so you can match both your ngram and regular analyzed text. Then at query time you can query both within a bool query so both "should" clauses matching will make the score higher of the document you want to have a higher score.

1 Like

OK thanks for your help. It works well

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.