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(%22a%22))&pretty" 


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

curl 
"http://127.0.0.1:9200/haystack/_search?q=(org%3A(%221%22)%20AND%20tags%3A(%22a%22))&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(%22a%22))
>
> 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(%221%22)%20AND%20tags%3A(%22a%22))
>
> 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 
> stackoverflow<http://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+unsubscr...@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.

Reply via email to