existsSearch
returns documents that contain an indexed value for a field
:
$searchResult = Book::existsSearch()
->field('description')
->execute();
ExistsQueryBuilder
doesn't provide any additional methods.
fuzzySearch
returns documents that contain terms similar to the search term:
$searchResult = Book::fuzzySearch()
->field('title')
->value('boko')
->execute();
Available methods provided by FuzzyQueryBuilder
:
Use field
to specify the field you wish to search:
$searchResult = Book::fuzzySearch()
->field('title')
->value('boko')
->execute();
fuzziness
controls maximum edit distance allowed for matching:
$searchResult = Book::fuzzySearch()
->field('title')
->value('boko')
->fuzziness('AUTO')
->execute();
You can use maxExpansions
to specify maximum number of terms to which the query will expand:
$searchResult = Book::fuzzySearch()
->field('title')
->value('boko')
->maxExpansions(50)
->execute();
prefixLength
is used to determine the number of beginning characters left unchanged when creating expansions:
$searchResult = Book::fuzzySearch()
->field('title')
->value('boko')
->prefixLength(0)
->execute();
rewrite
is used to rewrite the query:
$searchResult = Book::fuzzySearch()
->field('title')
->value('boko')
->rewrite('constant_score')
->execute();
transpositions
allows to include transpositions of two adjacent characters:
$searchResult = Book::fuzzySearch()
->field('title')
->value('boko')
->transpositions(true)
->execute();
With value
you can define a term you wish to find in the provided field
:
$searchResult = Book::fuzzySearch()
->field('title')
->value('boko')
->execute();
idsSearch
returns documents based on their IDs:
$searchResult = Book::idsSearch()
->values(['1', '2', '3'])
->execute();
prefixSearch
returns documents that contain a specific prefix in a provided field
:
$searchResult = Book::prefixSearch()
->field('title')
->value('boo')
->execute();
Available methods provided by PrefixQueryBuilder
:
Use field
to specify the field you wish to search:
$searchResult = Book::prefixSearch()
->field('title')
->value('boo')
->execute();
rewrite
is used to rewrite the query:
$searchResult = Book::prefixSearch()
->field('title')
->value('boo')
->rewrite('constant_score')
->execute();
With value
you can define beginning characters of terms you wish to find in the provided field
:
$searchResult = Book::prefixSearch()
->field('title')
->value('boo')
->execute();
rangeSearch
returns documents that contain terms within a provided range:
$searchResult = Book::rangeSearch()
->field('price')
->gt(100)
->execute();
Available methods provided by RangeQueryBuilder
:
boost
method allows you to decrease or increase the relevance scores of a query:
$searchResult = Book::rangeSearch()
->field('price')
->gt(100)
->boost(2)
->execute();
Use field
to specify the field you wish to search:
$searchResult = Book::rangeSearch()
->field('price')
->gt(100)
->execute();
format
is used to convert date values in the query:
$searchResult = Book::rangeSearch()
->field('updated_at')
->gt('2020-10-18')
->format('yyyy-MM-dd')
->execute();
gt
defines a greater than range:
$searchResult = Book::rangeSearch()
->field('price')
->gt(100)
->execute();
gte
defines a greater than or equal to range:
$searchResult = Book::rangeSearch()
->field('price')
->gte(100)
->execute();
lt
defines a less than range:
$searchResult = Book::rangeSearch()
->field('price')
->lt(100)
->execute();
lte
defines a less than or equal to range:
$searchResult = Book::rangeSearch()
->field('price')
->lte(100)
->execute();
You can use relation
to specify how the range query matches values for range fields:
$searchResult = Book::rangeSearch()
->field('price')
->gt(50)
->lt(100)
->relation('INTERSECTS')
->execute();
timeZone
is used to convert date values in the query to UTC:
$searchResult = Book::rangeSearch()
->field('updated_at')
->gt('2020-10-18')
->timeZone('+01:00')
->execute();
regexpSearch
returns documents that contain terms matching a regular expression:
$searchResult = Book::regexpSearch()
->field('title')
->value('b.*k')
->execute();
Available methods provided by RegexpQueryBuilder
:
Use field
to specify the field you wish to search:
$searchResult = Book::regexpSearch()
->field('title')
->value('b.*k')
->execute();
Use flags
to enable optional operators for the regular expression:
$searchResult = Book::regexpSearch()
->field('title')
->value('b.*k')
->flags('ALL')
->execute();
maxDeterminizedStates
defines the maximum number of automation states required for the query:
$searchResult = Book::regexpSearch()
->field('title')
->value('b.*k')
->maxDeterminizedStates(10000)
->execute();
rewrite
is used to rewrite the query:
$searchResult = Book::regexpSearch()
->field('title')
->value('b.*k')
->rewrite('constant_score')
->execute();
With value
you can define a regular expression for terms you wish to find in the provided field
:
$searchResult = Book::regexpSearch()
->field('title')
->value('b.*k')
->execute();
termSearch
returns documents that contain an exact term in a provided field:
$searchResult = Book::termSearch()
->field('price')
->value('300')
->execute();
Available methods provided by TermQueryBuilder
:
boost
method allows you to decrease or increase the relevance scores of a query:
$searchResult = Book::termSearch()
->field('price')
->value('300')
->boost(2)
->execute();
Use field
to specify the field you wish to search:
$searchResult = Book::termSearch()
->field('price')
->value('300')
->execute();
With value
you can define a term you wish to find in the provided field
:
$searchResult = Book::termSearch()
->field('price')
->value('300')
->execute();
termsSearch
returns documents that contain one or more exact terms in a provided field:
$searchResult = Book::termsSearch()
->terms('tags', ['available', 'new'])
->execute();
Available methods provided by TermsQueryBuilder
:
boost
method allows you to decrease or increase the relevance scores of a query:
$searchResult = Book::termsSearch()
->terms('tags', ['available', 'new'])
->boost(2)
->execute();
Use terms
to define array of terms you wish to find in the provided field:
$searchResult = Book::termsSearch()
->terms('tags', ['available', 'new'])
->execute();
wildcardSearch
returns documents that contain terms matching a wildcard pattern:
$searchResult = Book::wildcardSearch()
->field('title')
->value('bo*k')
->execute();
Available methods provided by WildcardQueryBuilder
:
boost
method allows you to decrease or increase the relevance scores of a query:
$searchResult = Book::wildcardSearch()
->field('title')
->value('bo*k')
->boost(2)
->execute();
Use field
to specify the field you wish to search:
$searchResult = Book::wildcardSearch()
->field('title')
->value('bo*k')
->execute();
rewrite
is used to rewrite the query:
$searchResult = Book::wildcardSearch()
->field('title')
->value('bo*k')
->rewrite('constant_score')
->execute();
With value
you can define a wildcard pattern for terms you wish to find in the provided field
:
$searchResult = Book::wildcardSearch()
->field('title')
->value('bo*k')
->execute();