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: Add and, or, and not filters #216

Closed
kimchy opened this issue Jun 8, 2010 · 3 comments
Closed

Query DSL: Add and, or, and not filters #216

kimchy opened this issue Jun 8, 2010 · 3 comments

Comments

@kimchy
Copy link
Member

kimchy commented Jun 8, 2010

Add support for and, or and not filters. In general, they are more performant then the bool filter. Here are some exampled:

and:

{
    "filtered" : {
        "query" : {
            "term" : { "name.first" : "shay" }
        },
        "filter" : {
            "and" : {
                "filters" : [
                    {
                        "term" : { "name.first" : "something" }
                    },
                    {
                        "term" : { "name.first" : "other" }
                    }
                ]
            }
        }
    }
}

or:

{
    "filtered" : {
        "query" : {
            "term" : { "name.first" : "shay" }
        },
        "filter" : {
            "or" : {
                "filters" : [
                    {
                        "term" : { "name.first" : "something" }
                    },
                    {
                        "term" : { "name.first" : "other" }
                    }
                ]
            }
        }
    }
}

not:

{
    "filtered" : {
        "query" : {
            "term" : { "name.first" : "shay" }
        },
        "filter" : {
            "not" : {
                "filter" :  {
                    "term" : { "name.first" : "someting" }
                }
            }
        }
    }
}
@kimchy
Copy link
Member Author

kimchy commented Jun 8, 2010

Query DSL: Add and, or, and not filters, closed by 6257b78

@bevankoopman
Copy link

Would it be possible to include an example of combining all three in one query; e.g., a search for A and B not C or D? Thanks.

@sahild
Copy link

sahild commented Apr 3, 2015

@bevankoopman +1 @kimchy @jaymode Would it be possible to include an example of combining all three in one query; e.g., a search for A and B not C or D? Thanks.

mindw pushed a commit to mindw/elasticsearch that referenced this issue Sep 5, 2022
MPC-1851: Add dev1 stack

Approved-by: Gideon Avida
costin pushed a commit that referenced this issue Dec 6, 2022
cbuescher pushed a commit to cbuescher/elasticsearch that referenced this issue Oct 2, 2023
cbuescher pushed a commit to cbuescher/elasticsearch that referenced this issue Oct 2, 2023
cbuescher pushed a commit to cbuescher/elasticsearch that referenced this issue Oct 2, 2023
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants