Neural Hybrid Query Stage
The Neural Hybrid Query stage performs hybrid lexical-semantic search that combines BM25-type lexical search with KNN dense vector search via Solr.
Not sure which hybrid query stage is right for you? Read about the differences between the hybrid query stages.
This feature is only available in Fusion 5.9.10 and later versions of Fusion 5.9. |
Prefiltering
Prefiltering is a technique that can improve performance and accuracy by filtering documents before applying the algorithm, reducing the number of documents that need to be processed. This is especially effective with the KNN algorithm.
Prefiltering is disabled by default. To enable it, uncheck Block pre-filtering in this stage.
When prefiltering is enabled, you can configure the filters using one or more of these methods:
-
Security filters
You can use security filters as prefilters by placing the Graph Security Trimming Stage after this one in the pipeline. Then Fusion uses the security trimming filter as a prefilter.
-
JavaScript
When prefiltering is enabled, this stage adds a
preFilterKey
object to the Javascriptctx
object. You can place a Javascript stage after this one and use it to access thepreFilterKey
object, as in this example:var QueryRequestAndResponse = Java.type('com.lucidworks.apollo.pipeline.query.QueryRequestAndResponse'); if(ctx.hasProperty("preFilterKey")) { var preFilter = ctx.getProperty("preFilterKey"); var wrapper = QueryRequestAndResponse.create(request,response,0) preFilter.addFilter(wrapper, 'id:* OR foo_s:bar'); }
-
Additional Query Parameters stage
If you do not want to create a JavaScript stage, you can create additional query parameters to prefilter the documents to be processed by using what the previous JavaScript example adds to the request. The following example uses a single prefilter:
"fq" = "{!bool filter=$vectorPreFilter}" "vectorPreFilter" = "EXAMPLE_FILTER"
The following example uses multiple prefilters:
"fq": "{!bool filter=$filterClauses}", "vectorPreFilter": "{!bool should=$filterClauses}", "filterClauses": ["id:EXAMPLE_FILTER1","id:EXAMPLE_FILTER2"]
Query pipeline stage condition examples
Stages can be triggered conditionally when a script in the Condition field evaluates to true. Some examples are shown below.
Run this stage only for mobile clients:
params.deviceType === "mobile"
Run this stage when debugging is enabled:
params.debug === "true"
Run this stage when the query includes a specific term:
params.q && params.q.includes("sale")
Run this stage when multiple conditions are met:
request.hasParam("fusion-user-name") && request.getFirstParam("fusion-user-name").equals("SuperUser");
!request.hasParam("isFusionPluginQuery")
The first condition checks that the request parameter "fusion-user-name" is present and has the value "SuperUser". The second condition checks that the request parameter "isFusionPluginQuery" is not present.
Configuration
When entering configuration values in the UI, use unescaped characters, such as \t for the tab character. When entering configuration values in the API, use escaped characters, such as \\t for the tab character.
|