Query Pipeline
Query pipelines are a unique functionality provided by on top of the OpenSearch engine. They are connected with indexes and help in making the search more precise and powerful. Query pipelines are further associated with query rules such as filters, aggregation appenders, and more.
To understand the concept of query pipelines better, we will create an example pipeline for the Harry Potter characters.
The API call to create a query pipeline is:
POST https://api.upstartcommerce.com/v1/search/query-pipelines
Notice that "query-pipelines" is explicitly mentioned in the API call.
The following code block is a representation of how to create a query pipeline.
Notice that the name of the index with which this query pipeline will be associated is explicitly mentioned in the indexes block as "hp_characters". This creates a link between the pipeline and the index.
Apart from the index, the name of the query pipeline i.e. "hprules" is also mentioned at the top.
Multiple functions such as CRUD operations and determination of properties can be performed via different API calls. You can find the remaining operations for APIs here.
Each query pipeline has a set of query rules that are applied to each query at the time of search. You can gain insight on the topic of query rules here.
For the sake of example, we will consider only one type of query rule i.e. filters.
The API call to create a filter query rule is:
POST https://api.upstartcommerce.com/v1/search/query-rules/hprules
Notice that the name of the query pipeline "hprules" is specified in the call. This links the created filter with the desired query pipeline.
The following code block represents the filter query rule. Once this filter is applied, every time a user searches the word half blood, the search result will show the values that have the ancestry of half blood in it.
The type of the query rule i.e. filter is specified at the end of the block through "CreateQueryRuleFacadeFilter".
Users can attach multiple query rules, search fields, synonyms, and other features in the query pipeline directly by using the following API call.
PUT https://api.upstartcommerce.com/v1/search/query-pipelines/pipeline_id/rules
The following code block represents the body of the attach function:
Notice that the name/id of existing features is mentioned in each code block.
It is important to remember that every time a new feature i.e. phrase detection/search field manager/filters is added to the query pipeline, all previously added or need to be added along with the new functions in the code block. Otherwise, the previously attached ones will no longer be attached to the respective query pipeline.
To ensure that the query rule is connected with the query pipeline, use the following endpoint:
POST https://api.upstartcommerce.com/v1/search/query-pipelines/hprules/analyse
Notice that the name of the respective query i.e. "hprules" is explicitly mentioned in the call.
Apart from determining the attached query rules, you can determine other properties of the query pipeline from this as well.