How exactly works "max_expansions" in match_phrase_prefix query?


(JJack_PL) #1

Example from page:

"match_phrase_prefix" : {
"message" : {
"query" : "this is a test",
"max_expansions" : 10
}
}

Can you give me some simple examples on this with different max_expansions numbers for example for query "a" and multi characters query like "test"?

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


(Clinton Gormley) #2

On Wed, 2013-02-20 at 03:33 -0800, JJack_PL wrote:

Example from page:
"match_phrase_prefix" : {
"message" : {
"query" : "this is a test",
"max_expansions" : 10
}
}
Can you give me some simple examples on this with different max_expansions numbers for example for query "a" and multi characters query like "test"?

In the example above, ES will examine all terms in the "message" field
to look for those that begin with the letters "test". It will combine
all of those terms into a query (eg "test","tester","testing","tests"
etc), working in alphabetical (lexicographic) order, up to
max_expansions.

Set max_expansions to limit the number of terms that will be collected.
Eg, if the prefix is "a" you may end up with thousands of terms, which
is pretty meaningless. Set max_expansions to (eg) 30 so that the user
gets some response, but your server is not overwhelmed by too many
clauses.

clint

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


(shgeorge) #3

In the above example if there are documents with terms : "test","tester","testing","tests"
and we are querying for "test" and "max_expansions" : 2, should it return only first 2 matching docs?

I see that it is returning all the matching docs. Could you please explain?


(system) #4