* Add documentation about setting a default model for neural search Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> * Add new processor to the processor list Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> * More tweaks Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> * Refactor search pipeline documentation Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> * Refactor retrieving search pipelines Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> * Add working examples Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> * Implement tech review comments Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> * Add responses to documentation Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> * Update _search-plugins/search-pipelines/neural-query-enricher.md Co-authored-by: Melissa Vagi <vagimeli@amazon.com> Signed-off-by: kolchfa-aws <105444904+kolchfa-aws@users.noreply.github.com> * Apply suggestions from code review Co-authored-by: Nathan Bower <nbower@amazon.com> Signed-off-by: kolchfa-aws <105444904+kolchfa-aws@users.noreply.github.com> --------- Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> Signed-off-by: kolchfa-aws <105444904+kolchfa-aws@users.noreply.github.com> Co-authored-by: Melissa Vagi <vagimeli@amazon.com> Co-authored-by: Nathan Bower <nbower@amazon.com>
4.0 KiB
layout, title, nav_order, has_children, parent, grand_parent
layout | title | nav_order | has_children | parent | grand_parent |
---|---|---|---|---|---|
default | Filter query | 10 | false | Search processors | Search pipelines |
Filter query processor
The filter_query
search request processor intercepts a search request and applies an additional query to the request, filtering the results. This is useful when you don't want to rewrite existing queries in your application but need additional filtering of the results.
Request fields
The following table lists all available request fields.
Field | Data type | Description |
---|---|---|
query |
Object | A query in query domain-specific language (DSL). For a list of OpenSearch query types, see Query DSL. Required. |
tag |
String | The processor's identifier. Optional. |
description |
String | A description of the processor. Optional. |
ignore_failure |
Boolean | If true , OpenSearch ignores any failure of this processor and continues to run the remaining processors in the search pipeline. Optional. Default is false . |
Example
The following example demonstrates using a search pipeline with a filter_query
processor.
Setup
Create an index named my_index
and index two documents, one public and one private:
POST /my_index/_doc/1
{
"message": "This is a public message",
"visibility":"public"
}
{% include copy-curl.html %}
POST /my_index/_doc/2
{
"message": "This is a private message",
"visibility": "private"
}
{% include copy-curl.html %}
Creating a search pipeline
The following request creates a search pipeline called my_pipeline
with a filter_query
request processor that uses a term query to return only public messages:
PUT /_search/pipeline/my_pipeline
{
"request_processors": [
{
"filter_query" : {
"tag" : "tag1",
"description" : "This processor is going to restrict to publicly visible documents",
"query" : {
"term": {
"visibility": "public"
}
}
}
}
]
}
{% include copy-curl.html %}
Using a search pipeline
Search for documents in my_index
without a search pipeline:
GET /my_index/_search
{% include copy-curl.html %}
The response contains both documents:
Response
{: .text-delta} ```json { "took" : 47, "timed_out" : false, "_shards" : { "total" : 1, "successful" : 1, "skipped" : 0, "failed" : 0 }, "hits" : { "total" : { "value" : 2, "relation" : "eq" }, "max_score" : 1.0, "hits" : [ { "_index" : "my_index", "_id" : "1", "_score" : 1.0, "_source" : { "message" : "This is a public message", "visibility" : "public" } }, { "_index" : "my_index", "_id" : "2", "_score" : 1.0, "_source" : { "message" : "This is a private message", "visibility" : "private" } } ] } } ```To search with a pipeline, specify the pipeline name in the search_pipeline
query parameter:
GET /my_index/_search?search_pipeline=my_pipeline
{% include copy-curl.html %}
The response contains only the document with public
visibility: