-
Notifications
You must be signed in to change notification settings - Fork 490
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
[DOC] Document the Derived Field feature #6943
Comments
Hi @rishabhmaurya , what is your ETA for producing the doc PR? To meet entrance criteria, the PR must be open and in review by 4/30. Thanks! |
@rishabhmaurya to add the PR for 2.14 related doc content. |
Doc in progress. |
Given this feature isn't complete yet - its missing aggregation and scoring support, we will move it out of 2.14 |
@rishabhmaurya will submit PR by end of day 6/6. Thanks! |
@hdhalter Here is the |
What do you want to do?
Tell us about your request. Provide a summary of the request and all versions that are affected.
Derived fields allows users to add or manipulate existing indexed fields by running scripts on the
_source
document. It eliminates the need to index or store these fields separately while still enabling queries on them. However, this flexibility comes with a trade-off in query latency, as each matching document is evaluated against these derived fields by loading the_source
document and running the script to determine if the document is a match.Meta issue: opensearch-project/OpenSearch#12281
RFC: opensearch-project/OpenSearch#1133
Key Benefits
Supported types
boolean
,keyword
,date
,long
,double
,geo_point
,ip
.What other resources are available?
Steps for testing -
Example 1
Step 1: Create Index Mapping with Derived Fields
In this example, we define a derived field
total_cost
that calculates the total cost by multiplying theprice
andquantity
fields.Step 2: Ingest Documents
We have indexed 5 documents representing various products with their prices and quantities.
Step 3: Query Based on Derived Field
This query retrieves documents where the
total_cost
is greater than or equal to 1000.Example 2
User sentiment analysis
Key Components
sentiment
- Calculates the sentiment of the text based on predefined rules.Step 1: Create Index Mapping with Derived Field
This mapping defines a derived field
sentiment
that assigns sentiment labels (positive, negative, neutral) based on specific keywords in the text, along with indexed fieldscategory
anduser_id
for context-based queries and user filtering.Step 2: Ingest Documents
We've indexed 3 documents with varying sentiments, categories, and user IDs for context-based queries and user filtering.
Step 3: Query Based on Sentiment, Indexed Fields, and User ID
Positive Sentiment in Personal Category for User ID "123"
This query retrieves documents with a positive sentiment in the personal category for the user with ID "123", combining sentiment analysis with indexed field queries and user filtering.
Definition of derived field in search request
The same example can be used to define the derived fields in search request, here is an example -
Step 1: Create index
Step 2: Ingest Documents
Step 3: Query Based on Sentiment, Indexed Fields, and User ID
The text was updated successfully, but these errors were encountered: