> 3) [ "apples and oranges"] //length =3, even with filter query (why not 1)?
>
> ...not an issue in my particular use case since all ingredients are 
> 1-word, but I would like to understand how to address case #3 above.
>

>From my experience with querying, ES slurps all values of an array into one 
large set of values and then indexes them. So from a normal matching 
perspective, including phrase matching, the following are equivalent:

"apples and oranges"
[ "apples and oranges" ]
[ "apples" "and" "oranges" ]

The big difference is in phrase queries with a position gap between 
individual values. When a position gap is added to a field's mappings, then 
a phase query for a phrase that spans across values requires a slop value 
that is sufficient to cross the gap.

So, for example, consider that a position gap of 4 was added to your 
ingredients field's mapping. Then:

ingredients:"apples and oranges" would match the first two but not the last 
one.
ingredients:"apples and oranges"~4 would match all of them, including the 
last one.

This implies to me that after the source has been analyzed and indexed, ES 
loses knowledge of the multiple values and knows only of tokens and their 
word positions. Therefore, I am guessing that the mvel length function 
counts the number of tokens, not the number of values in the source JSON.

Brian

-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/elasticsearch/3d95974e-9d78-46e3-a9f9-7a8b3ea3c2aa%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to