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

added option for custom elasticsearch queries and filters #52

Merged
merged 2 commits into from
Apr 9, 2020

Conversation

stedomedo
Copy link
Contributor

Added an option for custom queries and filters for elasticsearch.

An example filter can look like this:

filter = {"must": [{"term": {"tag": "irgendwas"}}, 
                   {"range": {"date": {"gte": "2020-01-01T00:00:00+0200"}}}]}

An example custom text query can look like this:

query = {"should": [{"match": {"text1": {"query": question, "boost": 2}}},
                    {"match": {"text2": question}}]}

@stedomedo stedomedo force-pushed the more_flexible_elastic_queries branch from 5f2efd5 to 702590e Compare April 3, 2020 19:13
@tholor tholor self-assigned this Apr 7, 2020
@tholor tholor added the type:feature New feature or request label Apr 7, 2020
@tholor
Copy link
Member

tholor commented Apr 7, 2020

Great, thanks for adding this @stedomedo!

Allowing custom queries and direct filters make a lot of sense.
We might also get rid of the current pre-filtering approach soon, as it doesn't make sense with Elasticsearch. It's mainly there for compatibility with current SQL-based documentstores.

I added a comment regarding the "terms" vs. "term" issue (and updated the docs). Can you please check if this fixes your issue?

@tholor tholor merged commit 0cffc6c into deepset-ai:master Apr 9, 2020
masci pushed a commit that referenced this pull request Nov 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:feature New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants