Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Query returns wrong/different results when in a percolator #7473

Closed
bejs opened this issue Aug 27, 2014 · 1 comment
Closed

Query returns wrong/different results when in a percolator #7473

bejs opened this issue Aug 27, 2014 · 1 comment

Comments

@bejs
Copy link

bejs commented Aug 27, 2014

First up, I'm using Elasticsearch v1.1.1

I am getting an unexpected result from a percolator. I have broken it down to it's simplest parts and it still not working as I it should.

Firstly I create a new index with mapping:

PUT /test1
{
   "mappings": {
      "product": {
         "properties": {
            "subject": {
               "type": "nested",
               "properties": {
                  "code": {
                     "type": "string"
                  }
               }
            }
         }
      }
   }
}

Then I create two objects for testing:

PUT /test1/product/12345
{
    "subject": {
        "code": "FA"
    }
}
PUT /test1/product/12346
{
    "subject": {
        "code": "BA"
    }
}

Then I create a query that I would expect to match on the second record only:

GET /test1/product/_search
{
   "query": {
      "filtered": {
         "query": {
            "match_all": []
         },
         "filter": {
            "bool": {
               "must_not": [
                  {
                     "query": {
                        "nested": {
                           "path": "subject",
                           "query": {
                              "prefix": {
                                 "subject.code": "fa"
                              }
                           }
                        }
                     }
                  }
               ]
            }
         }
      }
   }
}

So far everything is working as expected. The query returns the second record, the first one being excluded by the filter.

I then use the same query to create a percolator:

PUT /test1/.percolator/TEST
{
   "query": {
      "filtered": {
         "query": {
            "match_all": []
         },
         "filter": {
            "bool": {
               "must_not": [
                  {
                     "query": {
                        "nested": {
                           "path": "subject",
                           "query": {
                              "prefix": {
                                 "subject.code": "fa"
                              }
                           }
                        }
                     }
                  }
               ]
            }
         }
      }
   }
}

And test against both records:

GET /test1/product/12345/_percolate

GET /test1/product/12346/_percolate

They both return the same result:

{
   "took": 1,
   "_shards": {
      "total": 5,
      "successful": 5,
      "failed": 0
   },
   "total": 1,
   "matches": [
      {
         "_index": "test1",
         "_id": "TEST"
      }
   ]
}

I have tested this without a nested object and it operates as I would expect. At first I thought perhaps the match_all was doing something strange to the percolator but when it wasn't a nested object it worked fine.

@bejs bejs changed the title Percolator query not behaving the same as stand-alone query Query returns wrong/different results when in a percolator Aug 28, 2014
@clintongormley
Copy link

Hi @bejs

This issue was fixed in v1.2.2, see #6540.

thanks for good report though

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants