Sorry to keep replying to myself, but maybe someone will have a similar
problem in the future.
I realized that I didn't actually need to search in the array, just to
filter by known terms, so I switched its index property to "not_analyzed"
and now everything works as expected.
On Friday, August 9, 2013 10:32:03 AM UTC-7, Charles Pletcher wrote:
I think I might have figured out the problem. The above filter works, but
when I filter on "preschool-and-toddler", the query fails, presumably due
to unescaped dashes. Now I'm having trouble figuring out how best to escape
them. (This is probably also causing a problem when I index the data, so
I'll have to go back and fix that as well.)Any suggestions?
Thanks again!
On Friday, August 9, 2013 10:24:54 AM UTC-7, Charles Pletcher wrote:
Hi all,
I'm having trouble getting the syntax right for filtering based on the
terms that are contained in an array. I have documents that look like this:{ "_index": "category", "_type": "category", "_id": "16", "_score": 1, "_source": { "id": 16, "label": "Musical Toys", "small_label": "musical-toys", "active": 1, "cat_id": "1234_1234_1234_1234", "display_ages": [ "Baby", "Preschool & Toddler" ], "display_age_ids": [ 1, 2 ], "display_ages_big_label": [ "Baby", "Preschool & Toddler" ], "display_ages_small_label": [ "baby", "preschool-and-toddler" ], "sort_order": null } }
And I am trying to filter based on the strings in
_source.display_ages_small_label; but the following filter returns no hits:{
"filter":
{
"terms":
{
"display_ages_small_label": ["baby"]
}
}
}Based on my understanding of the documentation, I'd expect this filter to
return the above document and any other documents with "baby" in
display_ages_small_label--which is exactly what I'd want to happen. What am
I doing wrong, and how should I fix this?Thanks!
--
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.