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 post_filter query parameter #208

Closed
newgene opened this issue Mar 15, 2022 · 3 comments
Closed

Support post_filter query parameter #208

newgene opened this issue Mar 15, 2022 · 3 comments
Assignees

Comments

@newgene
Copy link
Member

newgene commented Mar 15, 2022

Typically working together with aggregation/facets, post_filter allows to filter hits list without changing total and aggregation output:

https://www.elastic.co/guide/en/elasticsearch/reference/8.1/filter-search-results.html#post-filter

For example:

{
  "query": {
    "query_string": {
      "query": "_exists_:@type",
      "default_operator": "AND",
      "lenient": true
    }
  },
  "aggs": {
    "@type": {
      "terms": {
        "field": "@type",
        "size": 100
      }
    }
  },
  "post_filter": {
    "term": {
      "@type": "Dataset"
    }
  },
  "size": 10
}

The new post_filter can be used to pass a query_string query to filter the matching hits:

query?q=_exists_:@type&post_filter=@type:Dataset
@colleenXu
Copy link

This looks interesting for BTE use (querying biothings apis), particularly since it looks like it would allow checking that a field exists AND that its value is X.

@newgene
Copy link
Member Author

newgene commented Aug 4, 2022

We already have an implementation at a particular API instance:

https://github.com/data2health/resource-discovery-api/blob/a7bdc531dde35511ca9ddcb252b58623693adfe3/web/pipeline.py#L73-L77

Now we should move this feature into biothings.web module to make it a generic query feature for all APIs.

@colleenXu
Copy link

will this work for the POST /query endpoint? As mentioned above, I'm interested in being able to check that a field exists while also querying for certain values in that field and other fields.

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