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 DSL: Empty bool {} should return match_all #7240

Closed
ppf2 opened this Issue Aug 12, 2014 · 2 comments

Comments

Projects
None yet
3 participants
@ppf2
Copy link
Member

commented Aug 12, 2014

This is somewhat related to the following request:
#6722

6722 actually causes a NPE when the clauses within the bool are null:

"bool" : {
    "must": [],
    "must_not": [],
    "should": []
  }

For this ticket, there are use cases when Kibana is generating requests like the following:

 "facet_filter": {
                "fquery": {
                    "query": {
                        "filtered": {
                            "query": {
                                "bool": {
                                }
                            },
                            "filter": {
                                "fquery": {
                                    "query": {
                                        "query_string": {
                                            "query": "_type:apache"
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }

The above query ignores the facet_filter's filter clause when it should really be returning a match_all plus the filter applied.

When a query with just a bool {} is run on its own, the empty bool clause in this case does not throw a NPE and is treated as a valid query, except that it returns no documents (when it should really be returning a match_all):

   "query": {
         "bool": {
         }
    }
@clintongormley

This comment has been minimized.

Copy link
Member

commented Aug 12, 2014

An empty bool filter or query should be treated as a match_all.

@brwe brwe self-assigned this Aug 12, 2014

@brwe brwe added v1.4.0 and removed adoptme labels Aug 12, 2014

brwe added a commit to brwe/elasticsearch that referenced this issue Aug 27, 2014

bool query: parser should return match_all in case there are no clauses
This also fixes has_parent filters with a nested empty bool filter
(see test SimpleChildQuerySearchTests#test6722, the test should actually expect
either 0 results when searching for has_parent "test" or one result when
search for has_parent "foo")

closes elastic#7240

@brwe brwe added v1.3.3 and removed v1.3.3 labels Aug 27, 2014

brwe added a commit that referenced this issue Aug 27, 2014

bool query: parser should return match_all in case there are no clauses
This also fixes has_parent filters with a nested empty bool filter
(see test SimpleChildQuerySearchTests#test6722, the test should actually expect
either 0 results when searching for has_parent "test" or one result when
search for has_parent "foo")

closes #7240
closes #7347

@brwe brwe closed this in 238efe5 Aug 27, 2014

brwe added a commit that referenced this issue Aug 27, 2014

bool query: parser should return match_all in case there are no clauses
This also fixes has_parent filters with a nested empty bool filter
(see test SimpleChildQuerySearchTests#test6722, the test should actually expect
either 0 results when searching for has_parent "test" or one result when
search for has_parent "foo")

closes #7240
closes #7347

@brwe brwe removed the v1.2.5 label Aug 27, 2014

@brwe

This comment has been minimized.

Copy link
Contributor

commented Aug 27, 2014

Fixed, but I did not push to 1.2 because this relies on a change that is also not on 1.2 (d414d89). Let me know if you need it on 1.2 as well.

@clintongormley clintongormley changed the title Empty bool {} should return match_all Query DSL: Empty bool {} should return match_all Sep 8, 2014

brwe added a commit that referenced this issue Sep 8, 2014

bool query: parser should return match_all in case there are no clauses
This also fixes has_parent filters with a nested empty bool filter
(see test SimpleChildQuerySearchTests#test6722, the test should actually expect
either 0 results when searching for has_parent "test" or one result when
search for has_parent "foo")

closes #7240
closes #7347

mute pushed a commit to mute/elasticsearch that referenced this issue Jul 29, 2015

bool query: parser should return match_all in case there are no clauses
This also fixes has_parent filters with a nested empty bool filter
(see test SimpleChildQuerySearchTests#test6722, the test should actually expect
either 0 results when searching for has_parent "test" or one result when
search for has_parent "foo")

closes elastic#7240
closes elastic#7347
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.