Personalize Search Ranking documentation (#4572)

* Add Personalize search ranking documentation

Signed-off-by: Fanit Kolchina <kolchfa@amazon.com>

* Add personalize search ranking processor

Signed-off-by: Fanit Kolchina <kolchfa@amazon.com>

* Table format

Signed-off-by: Fanit Kolchina <kolchfa@amazon.com>

* Fix link

Signed-off-by: Fanit Kolchina <kolchfa@amazon.com>

* Add link to processor

Signed-off-by: Fanit Kolchina <kolchfa@amazon.com>

* Change index name

Signed-off-by: Fanit Kolchina <kolchfa@amazon.com>

* Implemented review comments

Signed-off-by: Fanit Kolchina <kolchfa@amazon.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>

* Update personalize-search-ranking.md

Signed-off-by: kolchfa-aws <105444904+kolchfa-aws@users.noreply.github.com>

* Move Personalize up one section

Signed-off-by: Fanit Kolchina <kolchfa@amazon.com>

* Changes example

Signed-off-by: Fanit Kolchina <kolchfa@amazon.com>

---------

Signed-off-by: Fanit Kolchina <kolchfa@amazon.com>
Signed-off-by: kolchfa-aws <105444904+kolchfa-aws@users.noreply.github.com>
Co-authored-by: Nathan Bower <nbower@amazon.com>
This commit is contained in:
kolchfa-aws 2023-07-25 12:49:43 -04:00 committed by GitHub
parent 9db3bc44dd
commit 6d7d7d7c3d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 106 additions and 6 deletions

View File

@ -36,6 +36,7 @@ OpenSearch supports the following search request processors:
OpenSearch supports the following search response processors:
- [`rename_field`]({{site.url}}{{site.baseurl}}/search-plugins/search-pipelines/rename-field-processor/): Renames an existing field.
- [`personalize_search_ranking`]({{site.url}}{{site.baseurl}}/search-plugins/search-pipelines/personalize-search-ranking/): Uses [Amazon Personalize](https://aws.amazon.com/personalize/) to rerank search results (requires setting up the Amazon Personalize service).
## Viewing available processor types

View File

@ -0,0 +1,84 @@
---
layout: default
title: Personalize search ranking processor
nav_order: 40
has_children: false
parent: Search pipelines
grand_parent: Search
---
# Personalize search ranking processor
The `personalize_search_ranking` search response processor intercepts a search response and uses [Amazon Personalize](https://aws.amazon.com/personalize/) to rerank search results according to their Amazon Personalize ranking. This ranking is based on the user's past behavior and metadata about the search items and the user.
To use the `personalize_search_ranking` processor, you must first install the Amazon Personalize Search Ranking (`opensearch-search-processor`) plugin. For detailed instructions, see [Installing and configuring the Amazon Personalize Search Ranking plugin](https://docs.aws.amazon.com/personalize/latest/dg/opensearch-plugin-install.html).
{: .important}
## Request fields
The following table lists all available request fields.
Field | Data type | Description
:--- | :--- | :---
`campaign_arn` | String | The Amazon Resource Name (ARN) of the Amazon Personalize campaign used to personalize results. Required.
`recipe` | String | The name of the Amazon Personalize recipe to use. Currently, the only supported value for this field is `aws-personalized-ranking`. Required.
`weight` | Float | The weight to use with rankings provided by OpenSearch and Amazon Personalize. Valid values are in the [0.0, 1.0] range. The closer the weight is to 1.0, the more weight is given to Amazon Personalize as opposed to OpenSearch when calculating the ranking. If you specify 0.0, OpenSearch rankings are used. If you specify 1.0, Amazon Personalize rankings are used. Required.
`item_id_field` | String | If the `_id` field for an indexed document in OpenSearch doesn't correspond with your Amazon Personalize `itemId`, specify the name of the field that does. By default, the plugin assumes the `_id` data matches the `itemId` in your Amazon Personalize data.
`iam_role_arn` | String | If you use multiple roles to restrict permissions for different groups of users in your organization, specify the ARN of the role that has permission to access Amazon Personalize. If you use only the AWS credentials in your OpenSearch keystore, you can omit this field. Optional.
`tag` | String | The processor's identifier. Optional.
`description` | String | A description of the processor. Optional.
`ignore_failure` | Boolean | If `true`, OpenSearch [ignores any failure]({{site.url}}{{site.baseurl}}/search-plugins/search-pipelines/index/#ignoring-processor-failures) 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 `personalize_search_ranking` processor.
### Creating a search pipeline
The following request creates a search pipeline with a `personalize_search_ranking` response processor:
```json
PUT /_search/pipeline/my-pipeline
{
"description": "A pipeline to apply custom reranking from Amazon Personalize",
"response_processors" : [
{
"personalized_search_ranking" : {
"campaign_arn" : "Amazon Personalize Campaign ARN",
"item_id_field" : "productId",
"recipe" : "aws-personalized-ranking",
"weight" : "0.3",
"tag" : "personalize-processor",
"iam_role_arn": "Role ARN",
"aws_region": "AWS region"
}
}
]
}
```
{% include copy-curl.html %}
### Using a search pipeline
To search with a pipeline, specify the pipeline name in the `search_pipeline` query parameter. For example, the following request searches for comedies using the pipeline set up in the previous section:
```json
GET /movies/_search?search_pipeline=my-pipeline
{
"query": {
"multi_match": {
"query": "Comedy",
"fields": ["GENRES"]
}
},
"ext": {
"personalize_request_parameters": {
"user_id": "user ID",
"context": { "DEVICE" : "mobile phone" }
}
}
}
```
{% include copy-curl.html %}
For additional details, see [Personalizing search results from OpenSearch (self-managed)](https://docs.aws.amazon.com/personalize/latest/dg/personalize-opensearch.html).

View File

@ -104,15 +104,28 @@ Setting `size` to a high value (for example, larger than 250 documents) may degr
You cannot save a given comparison for future use, so Compare Search Results is not suitable for systematic testing.
{: .note}
## Comparing OpenSearch search results with re-ranked results
## Comparing OpenSearch search results with reranked results
One use case for Compare Search Results is to compare raw OpenSearch results with the same results processed by a re-ranking application. An example of such a re-ranker is **Kendra Intelligent Ranking for OpenSearch**, contributed by the Amazon Kendra team. This plugin takes search results from OpenSearch and applies Amazon Kendras semantic relevance rankings calculated using vector embeddings and other semantic search techniques. For many applications, this provides better result rankings.
One use case for Compare Search Results is the comparison of raw OpenSearch results with the same results processed by a reranking application. OpenSearch currently integrates with the following two rerankers:
- [Amazon Personalize Search Ranking](#personalizing-search-results-with-amazon-personalize-search-ranking)
- [Kendra Intelligent Ranking for OpenSearch](#reranking-results-with-kendra-intelligent-ranking-for-opensearch)
### Personalizing search results with Amazon Personalize Search Ranking
An example of a reranker is **Amazon Personalize Search Ranking**, contributed by the Amazon Personalize team. Amazon Personalize uses machine learning (ML) techniques to generate custom recommendations for your users. The plugin takes search results from OpenSearch and applies a [search pipeline]({{site.url}}{{site.baseurl}}/search-plugins/search-pipelines/index/) to rerank them according to their Amazon Personalize ranking. The Amazon Personalize rankings are based on the user's past behavior and metadata about the search items and the user. This workflow improves the search experience for your users by personalizing their search results.
To try Amazon Personalize Search Ranking, you must first set up Amazon Personalize. To get started, see [Amazon Personalize](https://aws.amazon.com/personalize/latest/dg/setup.html). For detailed information, including plugin setup instructions, see [Personalizing search results from OpenSearch (self-managed)](https://docs.aws.amazon.com/personalize/latest/dg/personalize-opensearch.html).
### Reranking results with Kendra Intelligent Ranking for OpenSearch
Another example of a reranker is **Kendra Intelligent Ranking for OpenSearch**, contributed by the Amazon Kendra team. This plugin takes search results from OpenSearch and applies Amazon Kendras semantic relevance rankings calculated using vector embeddings and other semantic search techniques. For many applications, this provides better result rankings.
To try Kendra Intelligent Ranking, you must first set up the Amazon Kendra service. To get started, see [Amazon Kendra](https://aws.amazon.com/kendra/). For detailed information, including plugin setup instructions, see [Intelligently ranking OpenSearch (self managed) results using Amazon Kendra](https://docs.aws.amazon.com/kendra/latest/dg/opensearch-rerank.html).
Once you've set up Kendra Intelligent Ranking, enter a query in **Query 1** and enter the same query using Kendra Intelligent Ranking in **Query 2**. Then compare the search results from OpenSearch and Amazon Kendra.
### Comparing search results with reranked results in OpenSearch Dashboards
### Example
To compare search results with reranked results in OpenSearch Dashboards, enter a query in **Query 1** and enter the same query using a reranker in **Query 2**. Then compare the search results from OpenSearch with reranked results.
The following example searches for the text "snacking nuts" in the `abo` index. The documents in the index contain snack descriptions in the `bullet_point` array.
@ -131,7 +144,7 @@ The following example searches for the text "snacking nuts" in the `abo` index.
"size": 25
}
```
1. Enter the same query with intelligent ranking in **Query 2**:
1. Enter the same query with a reranker in **Query 2**. This example uses Kendra Intelligent Ranking:
```json
{
@ -158,4 +171,6 @@ The following example searches for the text "snacking nuts" in the `abo` index.
```
In the preceding query, `body_field` refers to the body field of the documents in the index, which Kendra Intelligent Ranking uses to rank the results. The `body_field` is required, while the `title_field` is optional.
1. Select **Search** and compare the results in **Result 1** and **Result 2**.
1. Select **Search** and compare the results in **Result 1** and **Result 2**.
For an example walkthrough with Amazon Personalize, see [Comparing OpenSearch results with results from the plugin](https://docs.aws.amazon.com/personalize/latest/dg/opensearch-comparing-results.html).