Relevancy models are used by specifying them on a QueryRequest.
Query Request
The query request support specifying the relevancy models to use for computing scores for documents.
Multiple relevancy models can be specified on a QueryRequest at a time. When multiple relevancy models are specified, the first model that exists will be used. Relevancy models should be requested in priority order. The first relevancy model requested that is available will be used for calculating relevancy scores.
Multiple Relevancy Models
When capturing signal data for Training Relevancy Models, signal data must specify the names of the relevancy models that the signal data will be used for.
The simplest way to achieve this is to specify these relevancy model names on the QueryRequest, specifying any desired relevancy model first in priority order.
Alternatively, you can set the relevancy model names explicitly on the generated signals prior to adding them to the Signal Tracking API.
QueryRequest request = new QueryRequest("*:*"); request.setRelevancyModelNames("Engineering", "NorthAmerica", "Global");
http://<hostname>:<port>/rest/searchApi/simpleCgi?q=*:*&relevancyModelNames=Engineering%2CNorthAmerica%2CGlobal
Default Relevancy Model
If a query does not specify any relevancy models, it will use the relevancy model named "default".
No-Op Relevancy Model
A special relevancy model named "noop" is available in the default configuration. When using this relevancy model, no additional relevancy boosts will be added to the query. Each document in the result set will be scored using the standard TF/IDF function (which reflects the query term frequency in the document and the inverse document frequency of the term in the document collection).
QueryRequest request = new QueryRequest("travel"); request.setRelevancyModelNames("noop");
http://<hostname>:<port>/rest/searchApi/simpleCgi?q=travel&relevancyModelNames=noop
Default Sort
By default, results are sorted by relevancy. Sorting can be overridden; see Sorting Results.
Streaming Queries
Streaming queries will return results with no ordering by default. This is different from non-streaming queries that will return documents ordered by score by default. In order to return streaming queries ordered by score, you can do the following:
QueryRequest request = new QueryRequest("*:*"); request.addSort( SortSpecification.RELEVANCY_SORT ); ...
Query Response
When relevancy is enabled for a query, returned documents will be annotated with a Feature Vector that will indicate all the features of a document that can be used for evaluating relevancy.
This Feature Vector, along with other aspects of the document and query request can then be used as input to training data for Training Relevancy Models.
See Signal Tracking API for information on capturing signal information for a document.