Thanks, token_filter worked. Also, w/o modifying mapping, using script
filter<http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-script-filter.html>query
worked (query below). However, in both cases, ES seems to treat
multi-element array and array element with multiple words as having the
same token count. ie:
1) [ "apples", "oranges] //length=2
2) [ "apples" ] //length=1
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. Write a custom
Tokenizer?
*Script Filter query:*
{
"query" : {
"field": {
"ingredients": "apples"
}
},
"filter": {
"script": {
"script": "doc['ingredients'].values.length == 1"
}
}
}
On Wed, Jan 15, 2014 at 8:05 AM, InquiringMind <[email protected]>wrote:
> One thought occurred to me. Perhaps:
>
> 1. Build the token count into your ingredients field. Here's how:
> http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/mapping-core-types.html#token_count
>
> 2a. Pre-analyze your query arguments and remove the duplicates. For
> example, ingredients:"apples" ingredients:"apples".
>
> 2b. Add the token_count to your query, Based on the ES link and on the
> example in 2a, you would add ingredients.word_count:1 to your query. Now,
> in your set of 2 documents, document #1 would be filtered out of the
> response and only document #2 would be returned.
>
> Hope this helps!
>
> Brian
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "elasticsearch" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/elasticsearch/mvBrfBa5G0Y/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/elasticsearch/041ea39a-f1f0-43c8-a648-f06d614e71ba%40googlegroups.com
> .
>
> For more options, visit https://groups.google.com/groups/opt_out.
>
--
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/CAJwaA22aTQ5WDdU358DBJQtUN%2BcM8AOezg9bGNWvCkgx73HBNg%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.