Use matchAllSearch
to perform a search request, which
matches all documents:
$searchResult = Book::matchAllSearch()->execute();
MatchAllQueryBuilder
doesn't provide any additional methods.
matchNoneSearch
is the inverse
of matchAllSearch
:
$searchResult = Book::matchNoneSearch()->execute();
MatchNoneQueryBuilder
doesn't provide any additional methods.
Use matchPhrasePrefixSearch
to search for documents, that contain the words of a provided text,
in the same order as provided:
$searchResult = Book::matchPhrasePrefixSearch()
->field('title')
->query('My boo')
->execute();
Available methods provided by MatchPhrasePrefixQueryBuilder
:
analyzer
is used to convert the query
text into tokens:
$searchResult = Book::matchPhrasePrefixSearch()
->field('title')
->query('My boo')
->analyzer('english')
->execute();
Use field
to specify the field you wish to search:
$searchResult = Book::matchPhrasePrefixSearch()
->field('title')
->query('My boo')
->execute();
You can use maxExpansions
to specify maximum number of terms to which the last provided term of the query
value will expand:
$searchResult = Book::matchPhrasePrefixSearch()
->field('title')
->query('My boo')
->maxExpansions(50)
->execute();
Use query
to set the text you wish to find in the provided field
:
$searchResult = Book::matchPhrasePrefixSearch()
->field('title')
->query('My boo')
->execute();
Use slop
to define the maximum number of positions allowed between matching tokens:
$searchResult = Book::matchPhrasePrefixSearch()
->field('title')
->query('My boo')
->slop(0)
->execute();
You can define what to return in case analyzer
removes all tokens
with zeroTermsQuery
:
$searchResult = Book::matchPhrasePrefixSearch()
->field('title')
->query('My boo')
->zeroTermsQuery('none')
->execute();
Use matchPhraseSearch
to search for documents, which match the given phrase:
$searchResult = Book::matchPhraseSearch()
->field('title')
->query('My book')
->execute();
Available methods provided by MatchPhraseQueryBuilder
:
analyzer
is used to convert the query
text into tokens:
$searchResult = Book::matchPhraseSearch()
->field('title')
->query('My book')
->analyzer('english')
->execute();
Use field
to specify the field you wish to search:
$searchResult = Book::matchPhraseSearch()
->field('title')
->query('My book')
->execute();
Use query
to set the text you wish to find in the provided field
:
$searchResult = Book::matchPhraseSearch()
->field('title')
->query('My book')
->execute();
Use slop
to define the maximum number of positions allowed between matching tokens:
$searchResult = Book::matchPhraseSearch()
->field('title')
->query('My book')
->slop(0)
->execute();
You can define what to return in case analyzer
removes all tokens with zeroTermsQuery
:
$searchResult = Book::matchPhraseSearch()
->field('title')
->query('My book')
->zeroTermsQuery('none')
->execute();
Use matchSearch
for full-text search:
$searchResult = Book::matchSearch()
->field('title')
->query('My book')
->execute();
Available methods provided by MatchQueryBuilder
:
- analyzer
- autoGenerateSynonymsPhraseQuery
- boost
- field
- fuzziness
- fuzzyRewrite
- fuzzyTranspositions
- lenient
- maxExpansions
- minimumShouldMatch
- operator
- prefixLength
- query
- zeroTermsQuery
analyzer
is used to convert the query
text into tokens:
$searchResult = Book::matchSearch()
->field('title')
->query('My book')
->analyzer('english')
->execute();
autoGenerateSynonymsPhraseQuery
allows you to define, if match phrase queries have to be automatically created
for multi-term synonyms:
$searchResult = Book::matchSearch()
->field('title')
->query('My book')
->autoGenerateSynonymsPhraseQuery(true)
->execute();
boost
method allows you to decrease or increase the relevance scores of a query:
$searchResult = Book::matchSearch()
->field('title')
->query('My book')
->boost(2)
->execute();
Use field
to specify the field you wish to search:
$searchResult = Book::matchSearch()
->field('title')
->query('My book')
->execute();
fuzziness
controls maximum edit distance allowed for matching:
$searchResult = Book::matchSearch()
->field('title')
->query('My book')
->fuzziness('AUTO')
->execute();
fuzzyRewrite
is used to rewrite the query:
$searchResult = Book::matchSearch()
->field('title')
->query('My book')
->fuzzyRewrite('constant_score')
->execute();
Use fuzzyTranspositions
to allow transpositions for two adjacent characters:
$searchResult = Book::matchSearch()
->field('title')
->query('My book')
->fuzziness('AUTO')
->fuzzyTranspositions(true)
->execute();
Use lenient
to ignore format-based errors:
$searchResult = Book::matchSearch()
->field('price')
->query('My book')
->lenient(true)
->execute();
You can use maxExpansions
to specify maximum number of terms to which the query will expand:
$searchResult = Book::matchSearch()
->field('title')
->query('My book')
->maxExpansions(50)
->execute();
minimumShouldMatch
defines minimum number of clauses that must match for a document to be returned:
$searchResult = Book::matchSearch()
->field('title')
->query('My book')
->operator('OR')
->minimumShouldMatch(1)
->execute();
Use operator
to define the boolean logic used to interpret the query
text:
$searchResult = Book::matchSearch()
->field('title')
->query('My book')
->operator('OR')
->execute();
prefixLength
is used to determine the number of beginning characters left unchanged for fuzzy matching:
$searchResult = Book::matchSearch()
->field('title')
->query('My book')
->fuzziness('AUTO')
->prefixLength(0)
->execute();
Use query
to set the text you wish to find in the provided field
:
$searchResult = Book::matchSearch()
->field('title')
->query('My book')
->execute();
You can define what to return in case analyzer
removes all tokens
with zeroTermsQuery
:
$searchResult = Book::matchSearch()
->field('title')
->query('My book')
->zeroTermsQuery('none')
->execute();
Use multiMatchSearch
to preform full-text search in multiple fields:
$searchResult = Book::multiMatchSearch()
->fields(['title', 'description'])
->query('My book')
->execute();
Available methods provided by MultiMatchQueryBuilder
:
- analyzer
- autoGenerateSynonymsPhraseQuery
- boost
- fields
- fuzziness
- fuzzyRewrite
- fuzzyTranspositions
- lenient
- maxExpansions
- minimumShouldMatch
- operator
- prefixLength
- query
- slop
- tieBreaker
- type
- zeroTermsQuery
analyzer
is used to convert the query
text into tokens:
$searchResult = Book::multiMatchSearch()
->fields(['title', 'description'])
->query('My book')
->analyzer('english')
->execute();
autoGenerateSynonymsPhraseQuery
allows you to define, if match phrase queries have to be automatically created
for multi-term synonyms:
$searchResult = Book::multiMatchSearch()
->fields(['title', 'description'])
->query('My book')
->autoGenerateSynonymsPhraseQuery(true)
->execute();
boost
method allows you to decrease or increase the relevance scores of a query:
$searchResult = Book::multiMatchSearch()
->fields(['title', 'description'])
->query('My book')
->boost(2)
->execute();
Use fields
to define the fields you wish to search in:
$searchResult = Book::multiMatchSearch()
->fields(['title', 'description'])
->query('My book')
->execute();
fuzziness
controls maximum edit distance allowed for matching:
$searchResult = Book::multiMatchSearch()
->fields(['title', 'description'])
->query('My book')
->fuzziness('AUTO')
->execute();
fuzzyRewrite
is used to rewrite the query:
$searchResult = Book::multiMatchSearch()
->fields(['title', 'description'])
->query('My book')
->fuzzyRewrite('constant_score')
->execute();
Use fuzzyTranspositions
to allow transpositions for two adjacent characters:
$searchResult = Book::multiMatchSearch()
->fields(['title', 'description'])
->query('My book')
->fuzziness('AUTO')
->fuzzyTranspositions(true)
->execute();
Use lenient
to ignore format-based errors:
$searchResult = Book::multiMatchSearch()
->fields(['title', 'description'])
->query('My book')
->lenient(true)
->execute();
You can use maxExpansions
to specify maximum number of terms to which the query will expand:
$searchResult = Book::multiMatchSearch()
->fields(['title', 'description'])
->query('My book')
->maxExpansions(50)
->execute();
minimumShouldMatch
defines minimum number of clauses that must match for a document to be returned:
$searchResult = Book::multiMatchSearch()
->fields(['title', 'description'])
->query('My book')
->operator('OR')
->minimumShouldMatch(1)
->execute();
Use operator
to define the boolean logic used to interpret the query
text:
$searchResult = Book::multiMatchSearch()
->fields(['title', 'description'])
->query('My book')
->operator('OR')
->execute();
prefixLength
is used to determine the number of beginning characters left unchanged for fuzzy matching:
$searchResult = Book::multiMatchSearch()
->fields(['title', 'description'])
->query('My book')
->fuzziness('AUTO')
->prefixLength(0)
->execute();
Use query
to set the text you wish to find in the provided fields
:
$searchResult = Book::multiMatchSearch()
->fields(['title', 'description'])
->query('My book')
->execute();
Use slop
to define the maximum number of positions allowed between matching tokens:
$searchResult = Book::multiMatchSearch()
->fields(['title', 'description'])
->query('My book')
->slop(0)
->execute();
tieBreaker
is used to increase the relevance scores
of documents matching the query:
$searchResult = Book::multiMatchSearch()
->fields(['title', 'description'])
->query('My book')
->tieBreaker(0.3)
->execute();
Use type
to define how the query must be executed:
$searchResult = Book::multiMatchSearch()
->fields(['title', 'description'])
->query('My book')
->type('best_fields')
->execute();
Note, that not all the available methods make sense with every type. Read the documentation carefully.
You can define what to return in case analyzer
removes all tokens with zeroTermsQuery
:
$searchResult = Book::multiMatchSearch()
->fields(['title', 'description'])
->query('My book')
->zeroTermsQuery('none')
->execute();