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

[Elasticsearch] Optimize the final query #220

Open
dkarlovi opened this issue Mar 29, 2018 · 2 comments
Open

[Elasticsearch] Optimize the final query #220

dkarlovi opened this issue Mar 29, 2018 · 2 comments

Comments

@dkarlovi
Copy link
Contributor

dkarlovi commented Mar 29, 2018

Q A
Bug report? no
Feature request? yes
BC Break report? no
RFC? no

Currently, the final query generated for Elasticsearch is directly derived from the search condition. This can lead to verbose queries, for example for search condition name: foo you get:

{
    "query": {
        "bool": {
            "must": [
                {
                    "terms": {
                        "name": [
                            "foo"
                        ]
                    }
                }
            ]
        }
    }
}

Can be at least reduced to:

{
    "query": {
        "terms": {
            "name": [
                "foo"
            ]
        }
    }
}

We can also detect if we have exact or fuzzy matches and use filtered query (more examples of possible optimizations are linked).

@dkarlovi
Copy link
Contributor Author

Note, we can also apply source filtering to reduce network IO.

@dkarlovi
Copy link
Contributor Author

Also, we can deduce if the query is a "filter only" query and add a constant_score wrapper.

@sstok sstok added this to the 2.0 milestone Sep 28, 2020
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

2 participants