Hi, I faced the same problem as discussed here: How exactly works "max_expansions" in match_phrase_prefix query? - #2 by Clinton_Gormley
But this is still not answered.
I'm testing how match_phrase_prefix and max expanstion property works in Elasticsearch. Reffering to documentation of max expansion:
Then it looks at the sorted term dictionary to find the first 50 terms that begin with f, and adds these terms to the phrase query.
So I added 3 documents to my test index:
- trying out Elasticsearch
- trying out Elasticsearch2
- trying out Elasticsearch3
Then when I try to query this with max_expansion set to 2, I get all documents instead of 2.
GET /_search
{
"query": {
"match_phrase_prefix" : {
"message" : {
"query" : "trying out E",
"max_expansions" : 2
}
}
}
}
Result:
{
"took": 11,
"timed_out": false,
"_shards": {
"total": 34,
"successful": 34,
"skipped": 0,
"failed": 0
},
"hits": {
"total": 3,
"max_score": 1.7260926,
"hits": [
{
"_source": {
"message": "trying out Elasticsearch2"
}
},
{
"_source": {
"message": "trying out Elasticsearch"
}
},
{
"_source": {
"message": "trying out Elasticsearch3"
}
}
]
}
}