Odd behavior with AND condition


(mdj2) #1

When I run the query (tags:("a")) in elasticsearch, I get 0 results. My
query URL looks like:

http://127.0.0.1:9200/haystack/_search?q=(tags%3A("a"))

That is to be expected, since no objects have a tag set to "a".

Now when I change the condition, and add an AND, (org:("1") AND tags:("a"))
, I get 3 results back! The query URL looks like:

http://127.0.0.1:9200/haystack/_search?q=(org%3A("1")%20AND%20tags%3A("a"))

Getting more results back does not make any sense to me. I would expect
that kind of behavior with the OR operator, but AND? What is going on?

(This is a cross post from stackoverflowhttp://stackoverflow.com/questions/23568699/odd-behavior-with-and-condition-in-elasticsearch
)

--
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/2abd1b1b-edc0-4714-846f-8d8a82a39240%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


(mdj2) #2

This appears to be caused by the snowball analyzer which is used on the
"tags" field. To reproduce the odd behavior:

curl -XDELETE "http://localhost:9200/haystack"

curl -XPOST "http://localhost:9200/haystack/" -d '
{
"settings":{
"index":{}
}
}'

curl -XPOST "http://localhost:9200/haystack/modelresult/_mapping" -d '
{
"modelresult" : {
"_boost" : {
"name" : "boost",
"null_value" : 1.0
},
"properties" : {
"assigned_to" : {
"type" : "string",
"term_vector" : "with_positions_offsets",
"analyzer" : "snowball"
},
"clipped_from" : {
"type" : "long",
"index" : "analyzed"
},
"created_by" : {
"type" : "long",
"index" : "analyzed"
},
"django_ct" : {
"type" : "string"
},
"django_id" : {
"type" : "string"
},
"id" : {
"type" : "string"
},
"org" : {
"type" : "long",
"index" : "analyzed"
},
"tags" : {
"type" : "string",
"store" : true,
"term_vector" : "with_positions_offsets",
"analyzer" : "snowball"
},
"text" : {
"type" : "string",
"store" : true,
"term_vector" : "with_positions_offsets",
"analyzer" : "snowball"
},
"type" : {
"type" : "long",
"index" : "analyzed"
}
}
}
}'

curl -XPOST "http://localhost:9200/haystack/modelresult/" -d '{
"assigned_to": [],
"created_by": 1,
"django_ct": "preparations.preparation",
"django_id": "37",
"id": "preparations.preparation.37",
"org": 1,
"tags": [
"foo"
],
"text": "Wildlife.wmv\n:)\n",
"type": 2

}'

echo "Shows no results (good)"
curl "http://127.0.0.1:9200/haystack/_search?q=(tags%3A("a"))&pretty"

echo "Should show no results, but finds a match"

curl
"http://127.0.0.1:9200/haystack/_search?q=(org%3A("1")%20AND%20tags%3A("a"))&pretty"

Switching the tags field to the "standard" analyzer fixes the problem.

On Friday, May 9, 2014 3:31:08 PM UTC-7, md...@pdx.edu wrote:

When I run the query (tags:("a")) in elasticsearch, I get 0 results. My
query URL looks like:

http://127.0.0.1:9200/haystack/_search?q=(tags%3A("a"))

That is to be expected, since no objects have a tag set to "a".

Now when I change the condition, and add an AND, (org:("1") AND
tags:("a")), I get 3 results back! The query URL looks like:

http://127.0.0.1:9200/haystack/_search?q=(org%3A("1")%20AND%20tags%3A("a"))

Getting more results back does not make any sense to me. I would expect
that kind of behavior with the OR operator, but AND? What is going on?

(This is a cross post from stackoverflowhttp://stackoverflow.com/questions/23568699/odd-behavior-with-and-condition-in-elasticsearch
)

--
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/fcaddf25-7aa6-46e0-873d-d52d349ad5af%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


(system) #3