Skip to content

Wrong query processing #1983

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

Closed
azubanov opened this issue Apr 4, 2016 · 2 comments
Closed

Wrong query processing #1983

azubanov opened this issue Apr 4, 2016 · 2 comments

Comments

@azubanov
Copy link
Contributor

azubanov commented Apr 4, 2016

NEST/Elasticsearch.Net version: 2

Elasticsearch version: 2

Query:

            var fDescriptor = new QueryContainerDescriptor<TestObj>();
            var esFilters = new List<QueryContainer>();

            esFilters.Add(fDescriptor.Term(f => f.Field(o => o.Title).Value("1")));

            var res = client.Search<TestObj>(s => s.Query(q =>
                fDescriptor.Bool(b => b.Must(esFilters.ToArray())) ||
                (
                    (
                        q.Term(f => f.Field(o => o.Title).Value("3")) ||
                        q.Term(f => f.Field(o => o.Title).Value("4"))
                    ) &&
                    (
                        (
                            q.Term(f => f.Field(o => o.Title).Value("5")) ||
                            q.Term(f => f.Field(o => o.Title).Value("6"))
                        ) &&
                        (
                            q.Term(f => f.Field(o => o.Title).Value("7")) ||
                            q.Term(f => f.Field(o => o.Title).Value("8"))
                        )
                    )
                )
                ));

Result json:

POST /indexname/testobj/_search
{
  "query": {
    "bool": {
      "should": [
        {
          "bool": {
            "must": [
              {
                "term": {
                  "title": {
                    "value": "1"
                  }
                }
              }
            ]
          }
        },
        {
          "bool": {
            "should": [
              {
                "term": {
                  "title": {
                    "value": "3"
                  }
                }
              },
              {
                "term": {
                  "title": {
                    "value": "4"
                  }
                }
              },
              {
                "term": {
                  "title": {
                    "value": "5"
                  }
                }
              },
              {
                "term": {
                  "title": {
                    "value": "6"
                  }
                }
              },
              {
                "term": {
                  "title": {
                    "value": "7"
                  }
                }
              },
              {
                "term": {
                  "title": {
                    "value": "8"
                  }
                }
              }
            ]
          }
        }
      ]
    }
  }
}

Describe the issue:
wrong bool nesting. all conditions on the same level.

Mpdreamz added a commit that referenced this issue Apr 4, 2016
When combining (x || y) && (x || y) we should not flatten to a single
bool, this triggered a path not well tested. Added even more
combinatorial query dsl tests
@Mpdreamz
Copy link
Member

Mpdreamz commented Apr 4, 2016

Thanks for reporting @azubanov , this expoded a code path only covered by one test making the wrong assumption 👎

This should now be fixed and I've added several more tests surrounding this.

@azubanov
Copy link
Contributor Author

azubanov commented Apr 4, 2016

You fast as flash!

@russcam russcam added the v2.1.1 label Apr 5, 2016
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

3 participants