Match only arrays having one element

Hi! I have a 'not-analyzed' field where some categories are stored. Say,
category: ['a', 'b', 'c']. I need filter only documents which contains
category: ['a']. I did not found an out-of-box solution there in docs. As a
workaround I can store categories number in a separate field, but is there
more clear solution?

--

It could be something like maximum_match: 1 :slight_smile:

--

Can you sort categories alphabetically, concatenate them and store as a
single not-analyzed field? So, ['a', 'b', 'c'] would be stored as "a|b|c",
['c', 'a'] would be stored as "a|c" and ["a"] would be stored as "a". You
can apply the same conversion to your queries. Then you can search for
records that contain only categories that you are interested in and nothing
else.

On Wednesday, November 21, 2012 9:42:10 AM UTC-5, Eugene Nikolaev wrote:

It could be something like maximum_match: 1 :slight_smile:

--

Thanks, Igor, good idea! But I am inclined to store array size in a
separate field. Sorry, I've used a,b,c only for example - real categories
are a bit more complex than these.

--