Filtering on existing term in field returns nothing

Hello,

I am using ES-1.5.0. I can't for the life of me figure this out. I am
trying to do a simple filter query, like so:

{
"filter": {
"bool" : {
"must" : [
{"term": {"sentiment": "negative"}}
]
}
}
}

which returns something like:

{"took":7,"timed_out":false,"_shards":
{"total":5,"successful":5,"failed":0},
"hits":
{"total":1249,"max_score":1.0,
"hits":[{"_index":"myIndex","_type":"myType","_id":"92","_score":1.0,"_source":
{"topic":"Topic_4",
"sentiment":"negative"}}...

I highlighted the relevant bits. We can see it indeed filters only on
"negative" terms in the "sentiment" field. Now, when I try filtering only
for "Topic_4" in the "topic" field:

{
"filter": {
"bool" : {
"must" : [
{"term": {"topic": "Topic_4"}}
]
}
}
}

I get an empty array back:

{"took":2,"timed_out":false,"_shards":
{"total":5,"successful":5,"failed":0},
"hits":
{"total":0,"max_score":null,
"hits":[]}}

Even though we know "Topic_4" exists and my query syntax was identical.
Both fields are also mapped to strings. This is also true for any term I
try in the "topic" field.

Also, the reason I am using a boolean filter is because I eventually want
to find items that both have a certain topic and sentiment.

Any help would be greatly appreciated as I really have no idea what's going
on.

--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/35d8583a-9fdf-4337-86c1-3a7a448fc847%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

This is usually due to the field in question being analyzed with the
standard analyzer. which includes the "lowercase" token filter.
So the "topic" property of that document was indexed with "topic_4". A term
query/filter does not analyze the search value, so you are searching
for "Topic_4" in the index.

On Wednesday, April 15, 2015 at 5:56:35 PM UTC-4, Michael Czerny wrote:

Hello,

I am using ES-1.5.0. I can't for the life of me figure this out. I am
trying to do a simple filter query, like so:

{
"filter": {
"bool" : {
"must" : [
{"term": {"sentiment": "negative"}}
]
}
}
}

which returns something like:

{"took":7,"timed_out":false,"_shards":
{"total":5,"successful":5,"failed":0},
"hits":
{"total":1249,"max_score":1.0,

"hits":[{"_index":"myIndex","_type":"myType","_id":"92","_score":1.0,"_source":
{"topic":"Topic_4",
"sentiment":"negative"}}...

I highlighted the relevant bits. We can see it indeed filters only on
"negative" terms in the "sentiment" field. Now, when I try filtering only
for "Topic_4" in the "topic" field:

{
"filter": {
"bool" : {
"must" : [
{"term": {"topic": "Topic_4"}}
]
}
}
}

I get an empty array back:

{"took":2,"timed_out":false,"_shards":
{"total":5,"successful":5,"failed":0},
"hits":
{"total":0,"max_score":null,
"hits":}}

Even though we know "Topic_4" exists and my query syntax was identical.
Both fields are also mapped to strings. This is also true for any term I
try in the "topic" field.

Also, the reason I am using a boolean filter is because I eventually want
to find items that both have a certain topic and sentiment.

Any help would be greatly appreciated as I really have no idea what's
going on.

--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/eaac61b1-67fe-4f82-be82-22dcca002dcd%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ugh, it's always something really simple. I appreciate the help, you're a
lifesaver!

On Wednesday, April 15, 2015 at 7:35:50 PM UTC-4, Glen Smith wrote:

This is usually due to the field in question being analyzed with the
standard analyzer. which includes the "lowercase" token filter.
So the "topic" property of that document was indexed with "topic_4". A
term query/filter does not analyze the search value, so you are searching
for "Topic_4" in the index.

On Wednesday, April 15, 2015 at 5:56:35 PM UTC-4, Michael Czerny wrote:

Hello,

I am using ES-1.5.0. I can't for the life of me figure this out. I am
trying to do a simple filter query, like so:

{
"filter": {
"bool" : {
"must" : [
{"term": {"sentiment": "negative"}}
]
}
}
}

which returns something like:

{"took":7,"timed_out":false,"_shards":
{"total":5,"successful":5,"failed":0},
"hits":
{"total":1249,"max_score":1.0,

"hits":[{"_index":"myIndex","_type":"myType","_id":"92","_score":1.0,"_source":
{"topic":"Topic_4",
"sentiment":"negative"}}...

I highlighted the relevant bits. We can see it indeed filters only on
"negative" terms in the "sentiment" field. Now, when I try filtering only
for "Topic_4" in the "topic" field:

{
"filter": {
"bool" : {
"must" : [
{"term": {"topic": "Topic_4"}}
]
}
}
}

I get an empty array back:

{"took":2,"timed_out":false,"_shards":
{"total":5,"successful":5,"failed":0},
"hits":
{"total":0,"max_score":null,
"hits":}}

Even though we know "Topic_4" exists and my query syntax was
identical. Both fields are also mapped to strings. This is also true for
any term I try in the "topic" field.

Also, the reason I am using a boolean filter is because I eventually want
to find items that both have a certain topic and sentiment.

Any help would be greatly appreciated as I really have no idea what's
going on.

--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/d2d6e620-307f-4bf3-a1f5-a99f429fc2da%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.