-
Notifications
You must be signed in to change notification settings - Fork 507
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
Add documentation about setting a default model for neural search #5121
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
f220b27
Add documentation about setting a default model for neural search
kolchfa-aws 2d22bd6
Add new processor to the processor list
kolchfa-aws bf9d4b5
More tweaks
kolchfa-aws b717f28
Refactor search pipeline documentation
kolchfa-aws 543ce70
Refactor retrieving search pipelines
kolchfa-aws 225446b
Add working examples
kolchfa-aws 1420ff1
Implement tech review comments
kolchfa-aws e18b296
Add responses to documentation
kolchfa-aws b5d9fc6
Merge branch 'main' into default-neural-model
kolchfa-aws 6e974ab
Update _search-plugins/search-pipelines/neural-query-enricher.md
kolchfa-aws 1cc6a4b
Apply suggestions from code review
kolchfa-aws File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
156 changes: 156 additions & 0 deletions
156
_search-plugins/search-pipelines/creating-search-pipeline.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,156 @@ | ||
--- | ||
layout: default | ||
title: Creating a search pipeline | ||
nav_order: 10 | ||
has_children: false | ||
parent: Search pipelines | ||
grand_parent: Search | ||
--- | ||
|
||
# Creating a search pipeline | ||
|
||
Search pipelines are stored in the cluster state. To create a search pipeline, you must configure an ordered list of processors in your OpenSearch cluster. You can have more than one processor of the same type in the pipeline. Each processor has a `tag` identifier that distinguishes it from the others. Tagging a specific processor can be helpful when debugging error messages, especially if you add multiple processors of the same type. | ||
|
||
#### Example request | ||
|
||
The following request creates a search pipeline with a `filter_query` request processor that uses a term query to return only public messages and a response processor that renames the field `message` to `notification`: | ||
|
||
```json | ||
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" | ||
} | ||
} | ||
} | ||
} | ||
], | ||
"response_processors": [ | ||
{ | ||
"rename_field": { | ||
"field": "message", | ||
"target_field": "notification" | ||
} | ||
} | ||
] | ||
} | ||
``` | ||
{% include copy-curl.html %} | ||
|
||
## Ignoring processor failures | ||
|
||
By default, a search pipeline stops if one of its processors fails. If you want the pipeline to continue running when a processor fails, you can set the `ignore_failure` parameter for that processor to `true` when creating the pipeline: | ||
|
||
```json | ||
"filter_query" : { | ||
"tag" : "tag1", | ||
"description" : "This processor is going to restrict to publicly visible documents", | ||
"ignore_failure": true, | ||
"query" : { | ||
"term": { | ||
"visibility": "public" | ||
} | ||
} | ||
} | ||
``` | ||
|
||
If the processor fails, OpenSearch logs the failure and continues to run all remaining processors in the search pipeline. To check whether there were any failures, you can use [search pipeline metrics]({{site.url}}{{site.baseurl}}/search-plugins/search-pipelines/search-pipeline-metrics/). | ||
|
||
## Updating a search pipeline | ||
|
||
To update a search pipeline dynamically, replace the search pipeline using the Search Pipeline API. | ||
|
||
#### Example request | ||
|
||
The following example request upserts `my_pipeline` by adding a `filter_query` request processor and a `rename_field` response processor: | ||
|
||
```json | ||
PUT /_search/pipeline/my_pipeline | ||
{ | ||
"request_processors": [ | ||
{ | ||
"filter_query": { | ||
"tag": "tag1", | ||
"description": "This processor returns only publicly visible documents", | ||
"query": { | ||
"term": { | ||
"visibility": "public" | ||
} | ||
} | ||
} | ||
} | ||
], | ||
"response_processors": [ | ||
{ | ||
"rename_field": { | ||
"field": "message", | ||
"target_field": "notification" | ||
} | ||
} | ||
] | ||
} | ||
``` | ||
{% include copy-curl.html %} | ||
|
||
## Search pipeline versions | ||
|
||
When creating your pipeline, you can specify a version for it in the `version` parameter: | ||
|
||
```json | ||
PUT _search/pipeline/my_pipeline | ||
{ | ||
"version": 1234, | ||
"request_processors": [ | ||
{ | ||
"script": { | ||
"source": """ | ||
if (ctx._source['size'] > 100) { | ||
ctx._source['explain'] = false; | ||
} | ||
""" | ||
} | ||
} | ||
] | ||
} | ||
``` | ||
{% include copy-curl.html %} | ||
|
||
The version is provided in all subsequent responses to `get pipeline` requests: | ||
|
||
```json | ||
GET _search/pipeline/my_pipeline | ||
``` | ||
|
||
The response contains the pipeline version: | ||
|
||
<details open markdown="block"> | ||
<summary> | ||
Response | ||
</summary> | ||
{: .text-delta} | ||
|
||
```json | ||
{ | ||
"my_pipeline": { | ||
"version": 1234, | ||
"request_processors": [ | ||
{ | ||
"script": { | ||
"source": """ | ||
if (ctx._source['size'] > 100) { | ||
ctx._source['explain'] = false; | ||
} | ||
""" | ||
} | ||
} | ||
] | ||
} | ||
} | ||
``` | ||
</details> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we include a link to the search pipeline API documentation?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's really not a separate API page for this and I think in this case I'm just referring to the /_search/pipeline endpoint so it should be understandable.