Query not returning expected result

I have the following query:
{"filtered":{"query":{"query_string":{"query":"*"}},"filter":{"and":[{"term":{"active":true}},{"term":{"tenant":"4e669ec4139ad42bb8428031"}}]}}}

Which accurately returns the following result:
{ id: '4e7d7847a3e2486722000003',
firstName: 'Tets',
lastName: 'Test2',
email: '',
username: 'vailripper',
userType: 'member',
birthdate: '',
homePhone: '',
gender: 'Female',
active: true,
tags: [ 'sport-light', 'a test tag' ],
tenant: '4e669ec4139ad42bb8428031' }

However, when I add a a terms filter to filter on the 'a test tag' tag, it
doesn't return anything:

{"filtered":{"query":{"query_string":{"query":"*"}},"filter":{"and":[{"term":{"active":true}},{"term":{"tenant":"4e669ec4139ad42bb8428031"}},{"terms":{"tags":["a
test tag"]}}]}}}

In addition, if I add just a 'test' tag filter, it returns any tag with
'test' in its name, I was under the impression that it should only match on
the entire fields value?

{"filtered":{"query":{"query_string":{"query":"*"}},"filter":{"and":[{"term":{"active":true}},{"term":{"tenant":"4e669ec4139ad42bb8428031"}},{"terms":{"tags":["test"]}}]}}}

I Appreciate the Help,
Tyler

Are tags analyzed? (if you did not explicitly mapped them as not analyzed,
then they are). If so, then what happens is that they get analyzed, and
broken down into several terms ("test one" -> "test", "one"). Terms/term
filter does not do analysis, so "test one" will not match on anything
(since there isn't a term called "test one"), but "test" will (but it will
also match on a tag with "test two"). You can mark it as not analyzed in
the mappings, or use multi_field mapping to have it mapped both as analyzed
and not analyzed.

On Sun, Nov 13, 2011 at 4:19 AM, Tyler Schroeder vailripper@gmail.comwrote:

I have the following query:

{"filtered":{"query":{"query_string":{"query":"*"}},"filter":{"and":[{"term":{"active":true}},{"term":{"tenant":"4e669ec4139ad42bb8428031"}}]}}}

Which accurately returns the following result:
{ id: '4e7d7847a3e2486722000003',
firstName: 'Tets',
lastName: 'Test2',
email: '',
username: 'vailripper',
userType: 'member',
birthdate: '',
homePhone: '',
gender: 'Female',
active: true,
tags: [ 'sport-light', 'a test tag' ],
tenant: '4e669ec4139ad42bb8428031' }

However, when I add a a terms filter to filter on the 'a test tag' tag, it
doesn't return anything:

{"filtered":{"query":{"query_string":{"query":"*"}},"filter":{"and":[{"term":{"active":true}},{"term":{"tenant":"4e669ec4139ad42bb8428031"}},{"terms":{"tags":["a
test tag"]}}]}}}

In addition, if I add just a 'test' tag filter, it returns any tag with
'test' in its name, I was under the impression that it should only match on
the entire fields value?

{"filtered":{"query":{"query_string":{"query":"*"}},"filter":{"and":[{"term":{"active":true}},{"term":{"tenant":"4e669ec4139ad42bb8428031"}},{"terms":{"tags":["test"]}}]}}}

I Appreciate the Help,
Tyler

Yes, I'm using default the default mappings. In that case, shouldn't a
query with a ferms filter on tags, with the value of "a test tag" match a
record which has a tags value of "a test tag"? For example:

{"filtered":{"query":{"query_string":{"query":"*"}},"
filter":{"and":[{"term":{"active":true}},{"term":{"tenant":"
4e669ec4139ad42bb8428031"}},{"terms":{"tags":["a test tag"]}}]}}}

I guess I'm still confused as to why that query wouldn't match a record
like the one in my original post. It seems that even if it were matching on
an analyzed field, all 3 terms ("a", "test", "tag") exist in the tags
array, therefore it should match?

("a", "test", "tag") are the analyzed terms and exists in the index (well,
"a" is not because its a stop word). But, when you try and match on a
single term of "test tag", it won't match on either "test" or "tag".

On Mon, Nov 14, 2011 at 2:52 AM, Tyler Schroeder vailripper@gmail.comwrote:

Yes, I'm using default the default mappings. In that case, shouldn't a
query with a ferms filter on tags, with the value of "a test tag" match a
record which has a tags value of "a test tag"? For example:

{"filtered":{"query":{"query_string":{"query":"*"}},"
filter":{"and":[{"term":{"**active":true}},{"term":{"tenant":"
4e669ec4139ad42bb8428031"}},{"**terms":{"tags":["a test tag"]}}]}}}

I guess I'm still confused as to why that query wouldn't match a record
like the one in my original post. It seems that even if it were matching on
an analyzed field, all 3 terms ("a", "test", "tag") exist in the tags
array, therefore it should match?