In my docs, there is a product_code field containing a string value similar to pc00XXa , where X is replaced by some digit 1..9. I expect a result of 9 documents with this phrase prefix:
{ "query": { "match": { "_all": { "query": "pc001", "type": "phrase_prefix" } } } }
... but the result is empty. Using product_code instead of _all , I get the expected 9 documents.
Using a prefix request instead of a phrase prefix request seems to work as expected with the _all and product_code fields. The following query gives me 9 documents:
{ "query": { "prefix": { "_all": { "value": "pc001" } } } }
Elasticsearch documentation says: "Match_phrase_prefix matches match_phrase, except that it allows the use of prefix matches in the last term in the text." In my case, I have only one term in the request, so I expect it to work as a prefix.
How exactly does a phrase prefix request differ from a prefix request when the request contains one term? And why using _all gives me fewer results than explicitly specifying a field name?
source share