Use existing DSL query pipelines with Commerce Studio
DSL does not work with Commerce Studio. If you have existing query pipelines with DSL that you want to use with Commerce Studio, instead of recreating the entire pipeline, Lucidworks can keep the pipeline and remove DSL by doing the following.-
For DSL-enabled pipelines where supported search mode =
allordsl, selectlegacyoption instead. -
Update or disable pipeline stages used solely for DSL.
- For query stage parameters, remove any fields with DSL values mapped.
- In JavaScript, comment out or remove instances of
with(DSL)code blocks.
Why Search DSL
Lucidworks Search Search Domain Specific Language (DSL) reduces search query complexity for the user. Lucidworks Search Search DSL supports expressive search queries and responses via a structured, modern JSON format. Search DSL is an alternative to the current (now referred to as) “Legacy” format for performing search queries. Previously, users needed to understand complex syntax to express certain search queries in Lucidworks Search (for example, the best way to express a facet filter). Compared to the legacy Solr parameter format, Search DSL is structured to more closely align with the central concepts of Lucidworks Search and provide a more usable alternative for expressing complex Lucidworks Search queries. Search DSL gives Lucidworks Search control over how to execute a query by transforming a structured query input into a Solr request, at which time Lucidworks Search can add intelligence around the index and the user’s intent.Limitations
Despite the advantages, there are still some important limitations to be aware of when deciding whether to use the Lucidworks Search Search DSL.These limitations only apply to DSL queries. Legacy queries can still be issued separately from DSL queries without being subject to these limitations.
-
Head / Tail Rewrite. Support is currently limited when using DSL queries:
- In order to work on DSL queries, the
Improved Querymust be entered in as a JSON string representing the desiredmainquery that should be issued (this replaces thequeryDefinition.mainfield in the rewritten DSL query) - The query rewrites produced by the built-in head/tail rewrite job will NOT work on DSL queries, as the job only outputs legacy-style rewrites
- In order to work on DSL queries, the
- Query Stage Support. All query stages are fully supported
-
Rules Support. All kinds of rules are fully supported with the exceptions noted below
- Set Params. Not supported
- Custom Rule. Not supported
Request format
This section describes each top-level field of a Search DSL request.Overview
The Search DSL format is supported in the following endpoints:
In all cases, it should be a POST with a
Content-Type: application/json header.
The below table briefly summarizes the function of each of the top-level fields.
The following sections provide an example of each field in use.
More detailed information on each field can be found in the Lucidworks Search API Javadocs.
queryDefinition
queryDefinition defines the logic of what to query for. The above example queries for “cyberpunk novels” against the body_t field, additionally filtering to only show matches that have “books” in the category_t field.
results
results defines how the results should be displayed and organized. The above example is set to show the next 20 results starting from the 21st matched document (as with Solr, start is 0-based). Additionally, results will be grouped by author, showing 5 results per group. In the DSL response, the head document of each group will show up in the results list with the other documents in the group in the head doc’s groupedDocs field.
facets
facets field controls faceting for the query. In the above example, faceting is enabled on the category field (limiting to show only 5 values), brand field (showing all values starting from the 11th value), and published_dt field (showing 1 year increments between 2006 and 2020).
context
context field accepts parameters used by various query stages as well as DSL hints. In the above example, the tags parameter has been specified for the Apply Rules stage which will cause only rules with the “sometag” tag to be triggered. The lw.rules.debug parameter has also been specified to return extra rule triggering information in the response.
params
params field allows arbitrary query parameters to be added to the underlying Solr query and is also used to supply Security Trimming Stage parameters. In the above query, the user’s id has been supplied for the Security Trimming Stage.
Response format
This section describes each top-level field of a Search DSL response.Overview
The below table briefly summarizes the function of each of the top-level fields. The following sections provide an example of each field in a real response (some parts omitted for brevity).results
results field holds the results list with pagination info, scoring, and hit count. In the above, grouping has been performed on the author field.
facets
facets field holds the returned facets and facet values. In the above, we see facet results for the category field and a range facet on the published_dt field, each of which has a corresponding label configured via a Set Facets rule for a user-friendly display name for the facet.
rules
rules field holds data returned by any rules that triggered. In the above, 3 rules have triggered. A Set Facets rule created a facet_labels entry defining the desired ordering and labels for the facets (the labels are also present in the facets section of the response). Two JSON Blob rules of type default have triggered, the first blob in the list having a higher precedence value than the second (and thus appearing first).
spellcheck
spellcheck field holds all the spelling suggestions. Above, the query has misspelled “scotch whiskey” as “scoch whiskeys” and a number of suggestions are provided for each word as well as a collation with the fully corrected query.
meta
meta field holds assorted metadata about the query, such as timing and debug information. Above, in the timing.mainQuery field we see that the underlying Solr query took 14 ms (taken from Solr’s QTime) while the total field shows that the entire DSL query took 105 ms. The timings of individual pipeline stages are broken down in the pipeline field. The debug field here shows the various parameters that were sent in the underlying Solr query.