This topic describes how to disable spelling correction and DYM suggestions on individual queries.
You may discover that it is desirable to disable spelling correction in order to reduce the cost of running some queries in performance-sensitive applications. For example:
Queries where the MDEX Engine needs to perform matching on a very large number of terms all of which need to be ranked for spelling correction suggestions.
Queries using terms derived directly from the raw data. For example, if your end users are searching for terms that are unique to their field, it may be desirable to disable spelling correction suggestions for those terms.
To disable spelling correction for a particular query:
Use a query configuration option,
spell
, with a parameternospell
.This option has the following characteristics:
Requires spelling to be enabled in Dgidx or in the dgraph. Otherwise, this option has no effect.
Requires that you provide a
nospell
parameter to it. Providing a parameter other thannospell
results in a warning in the error log, and spelling correction proceeds as if the option were not provided to the MDEX Engine.Reduces the performance cost of a particular query. You can include this option in your front-end application for particular queries if you observe that disabling spelling correction is beneficial for increasing performance of your application overall. However, there is no need to modify your existing application if you don't observe a performance penalty from using spelling correction.
Example 80. Examples
In the presentation API, use the
spell+nospell
option with
Ntx
and
Dx
parameters.
For example, to disable spelling correction for a dimension search
query for
"blue suede shoes"
, change the query from this
syntax:
D=blue+suede+shoes&Dx=mode+matchallpartial
To the following syntax:
D=blue+suede+shoes&Dx=mode+matchallpartial+spell+nospell
In the dgraph URL, specify the
spell+nospell
value to the
opts
parameter. For example, change this type of query
from this syntax:
/search?terms=blue+suede+shoes&opts=mode+matchallpartial
To the following syntax:
/search?terms=blue+suede+shoes&opts=mode+matchallpartial+spell+nospell
In the Java Presentation API, you can disable spelling for a specific query as shown in this example:
ENEQuery nequery = new ENEQuery(); nequery.setDimSearchTerms("blue suede shoes"); nequery.setDimSearchOpts("spell nospell");
In the .NET API, you can disable spelling for a specific query as shown in this example:
ENEQuery nequery = new ENEQuery(); nequery.DimSearchTerms = "blue suede shoes"; nequery.DimSearchOpts = "spell nospell";