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

support filter query parameter #296

Open
newgene opened this issue Sep 14, 2023 · 3 comments
Open

support filter query parameter #296

newgene opened this issue Sep 14, 2023 · 3 comments

Comments

@newgene
Copy link
Member

newgene commented Sep 14, 2023

Difference between query and filter context in an ES query:

https://www.elastic.co/guide/en/elasticsearch/reference/current/query-filter-context.html

The query placed in the filter context can be faster than in the normal query context (e.g. passed to q query parameter):

  • filter query does not included in the _score calculation
  • filter query can be cached by ES

When implemented, we can change this API query:

?q=object.umls:C0872079 AND pmid_count:>5 AND predicate:LOCATION_OF

to

?q=object.umls:C0872079&filter=pmid_count:>5 AND predicate:LOCATION_OF

They should return the same list of hits, but it would be preferred if the part of filter query is used repetitively while the q query changes.

@newgene
Copy link
Member Author

newgene commented Sep 14, 2023

filter query parameter should work for both GET and POST for the query handler.

Note that we currently used filter to be an alias of fields parameter, for the back-compatiblity, but it's no longer an issue, so we can remove that alias and reuse it for different functionality.

@newgene
Copy link
Member Author

newgene commented Sep 14, 2023

We already have a similar implementation in one of API instance:

https://github.com/NIAID-Data-Ecosystem/nde-discovery-api/blob/08dfae752613b45647f8ce83350466733ea1e6e6/nde-web/pipeline.py#L64 (called extra_filter but does the same feature)

@newgene
Copy link
Member Author

newgene commented Sep 14, 2023

Also want to note that this is related to post_filter query parameter from #208. The key difference is post_filter does not impact the aggregation results, while filter does, so typically, these two related query parameters will be used in difference scenarios.

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

1 participant