ejsFuzzyLikeThisQuery

Fuzzy like this query find documents that are “like” provided text by running it against one or more fields.

Fuzzifies ALL terms provided as strings and then picks the best n differentiating terms. In effect this mixes the behaviour of FuzzyQuery and MoreLikeThis but with special consideration of fuzzy scoring factors. This generally produces good results for queries where users may provide details in a number of fields and have no knowledge of boolean query syntax and also want a degree of fuzzy matching and a fast query.

For each source term the fuzzy variants are held in a BooleanQuery with no coord factor (because we are not looking for matches on multiple variants in any one doc). Additionally, a specialized TermQuery is used for variants and does not use that variant term’s IDF because this would favour rarer terms eg misspellings. Instead, all variants use the same IDF ranking (the one for the source query term) and this is factored into the variant’s boost. If the source query term does not exist in the index the average IDF of the variants is used.

Module

 FuzzyLikeThisQuery

FuzzyLikeThisQuery ( likeText )

Constructs a query where each documents returned are “like” provided text


Parameters
likeText <String> The text to find documents like it.

Method Summary

Returns Name Description
String_type()The type of ejs object. For internal use only.
Objectanalyzer(analyzerName)The analyzer that will be used to analyze the text. Defaults to the analyzer associated with the field.
Objectboost(boost)Sets the boost value for documents matching the Query.
ObjectfailOnUnsupportedField(trueFalse)Should the Query fail when an unsupported field is specified. Defaults to true.
Objectfields(f)The fields to run the query against. If you call with a single field, it is added to the existing list of fields. If called with an array of field names, it replaces any existing values with the new array.
ObjectignoreTf(trueFalse)Should term frequency be ignored. Defaults to false.
ObjectlikeText(s)The text to find documents like
ObjectmaxQueryTerms(max)The maximum number of query terms that will be included in any generated query. Defaults to 25.
ObjectminSimilarity(min)The minimum similarity of the term variants. Defaults to 0.5.
ObjectprefixLength(len)Length of required common prefix on variant terms. Defaults to 0..
StringtoJSON()Retrieves the internal query object. This is typically used by internal API functions so use with caution.

Method Detail

 _type

String _type ( )
The type of ejs object. For internal use only.

Returns
the type of object

 analyzer

Object analyzer ( analyzerName )
The analyzer that will be used to analyze the text. Defaults to the analyzer associated with the field.

Parameters
analyzerName <String> The name of the analyzer.
Returns
returns this so that calls can be chained.

 boost

Object boost ( boost )
Sets the boost value for documents matching the Query.

Parameters
boost <Double> A positive double value.
Returns
returns this so that calls can be chained.

 failOnUnsupportedField

Object failOnUnsupportedField ( trueFalse )
Should the Query fail when an unsupported field is specified. Defaults to true.

Parameters
trueFalse <Boolean> A boolean value
Returns
returns this so that calls can be chained.

 fields

Object fields ( f )
The fields to run the query against. If you call with a single field, it is added to the existing list of fields. If called with an array of field names, it replaces any existing values with the new array.

Parameters
f <String | String[]> A single field name or a list of field names.
Returns
returns this so that calls can be chained.

 ignoreTf

Object ignoreTf ( trueFalse )
Should term frequency be ignored. Defaults to false.

Parameters
trueFalse <Boolean> A boolean value
Returns
returns this so that calls can be chained.

 likeText

Object likeText ( s )
The text to find documents like

Parameters
s <String> A text string.
Returns
returns this so that calls can be chained.

 maxQueryTerms

Object maxQueryTerms ( max )
The maximum number of query terms that will be included in any generated query. Defaults to 25.

Parameters
max <Integer> A positive integer value.
Returns
returns this so that calls can be chained.

 minSimilarity

Object minSimilarity ( min )
The minimum similarity of the term variants. Defaults to 0.5.

Parameters
min <Double> A positive double value.
Returns
returns this so that calls can be chained.

 prefixLength

Object prefixLength ( len )
Length of required common prefix on variant terms. Defaults to 0..

Parameters
len <Integer> A positive integer value.
Returns
returns this so that calls can be chained.

 toJSON

String toJSON ( )
Retrieves the internal query object. This is typically used by internal API functions so use with caution.

Returns
returns this object's internal query property.

Request

Queries

Filters

Aggregations

Facets

Suggesters

Geo