You can use Elastic\ScoutDriverPlus\Support\Query::exists()
to build a query that matches documents, which
contain an indexed value for a field
:
$query = Query::exists()->field('description');
$searchResult = Book::searchQuery($query)->execute();
You can use Elastic\ScoutDriverPlus\Support\Query::fuzzy()
to build a query that matches documents, which
contain terms similar to the search term:
$query = Query::fuzzy()
->field('title')
->value('boko');
$searchResult = Book::searchQuery($query)->execute();
Available methods:
Use field
to specify the field you wish to search:
$query = Query::fuzzy()
->field('title')
->value('boko');
$searchResult = Book::searchQuery($query)->execute();
fuzziness
controls maximum edit distance allowed for matching:
$query = Query::fuzzy()
->field('title')
->value('boko')
->fuzziness('AUTO');
$searchResult = Book::searchQuery($query)->execute();
You can use maxExpansions
to specify maximum number of terms to which the query will expand:
$query = Query::fuzzy()
->field('title')
->value('boko')
->maxExpansions(50);
$searchResult = Book::searchQuery($query)->execute();
prefixLength
is used to determine the number of beginning characters left unchanged when creating expansions:
$query = Query::fuzzy()
->field('title')
->value('boko')
->prefixLength(0);
$searchResult = Book::searchQuery($query)->execute();
rewrite
is used to rewrite the query:
$query = Query::fuzzy()
->field('title')
->value('boko')
->rewrite('constant_score');
$searchResult = Book::searchQuery($query)->execute();
transpositions
allows to include transpositions of two adjacent characters:
$query = Query::fuzzy()
->field('title')
->value('boko')
->transpositions(true);
$searchResult = Book::searchQuery($query)->execute();
With value
you can define a term you wish to find in the provided field
:
$query = Query::fuzzy()
->field('title')
->value('boko');
$searchResult = Book::searchQuery($query)->execute();
You can use Elastic\ScoutDriverPlus\Support\Query::ids()
to build a query that matches documents
based on their IDs:
$query = Query::ids()->values(['1', '2', '3']);
$searchResult = Book::searchQuery($query)->execute();
You can use Elastic\ScoutDriverPlus\Support\Query::prefix()
to build a query that matches documents, which
contain a specific prefix in a provided field
:
$query = Query::prefix()
->field('title')
->value('boo');
$searchResult = Book::searchQuery($query)->execute();
Available methods:
caseInsensitive
is used to allow ASCII case insensitive matching:
$query = Query::prefix()
->field('title')
->value('boo')
->caseInsensitive(true);
$searchResult = Book::searchQuery($query)->execute();
Use field
to specify the field you wish to search:
$query = Query::prefix()
->field('title')
->value('boo');
$searchResult = Book::searchQuery($query)->execute();
rewrite
is used to rewrite the query:
$query = Query::prefix()
->field('title')
->value('boo')
->rewrite('constant_score');
$searchResult = Book::searchQuery($query)->execute();
With value
you can define beginning characters of terms you wish to find in the provided field
:
$query = Query::prefix()
->field('title')
->value('boo');
$searchResult = Book::searchQuery($query)->execute();
You can use Elastic\ScoutDriverPlus\Support\Query::range()
to build a query that matches documents, which
contain terms within a provided range:
$query = Query::range()
->field('price')
->gt(100);
$searchResult = Book::searchQuery($query)->execute();
Available methods:
boost
method allows you to decrease or increase the relevance scores of a query:
$query = Query::range()
->field('price')
->gt(100)
->boost(2);
$searchResult = Book::searchQuery($query)->execute();
Use field
to specify the field you wish to search:
$query = Query::range()
->field('price')
->gt(100);
$searchResult = Book::searchQuery($query)->execute();
format
is used to convert date values in the query:
$query = Query::range()
->field('updated_at')
->gt('2020-10-18')
->format('yyyy-MM-dd');
$searchResult = Book::searchQuery($query)->execute();
gt
defines a greater than range:
$query = Query::range()
->field('price')
->gt(100);
$searchResult = Book::searchQuery($query)->execute();
gte
defines a greater than or equal to range:
$query = Query::range()
->field('price')
->gte(100);
$searchResult = Book::searchQuery($query)->execute();
lt
defines a less than range:
$query = Query::range()
->field('price')
->lt(100);
$searchResult = Book::searchQuery($query)->execute();
lte
defines a less than or equal to range:
$query = Query::range()
->field('price')
->lte(100);
$searchResult = Book::searchQuery($query)->execute();
You can use relation
to specify how the range query matches values for range fields:
$query = Query::range()
->field('price')
->gt(50)
->lt(100)
->relation('INTERSECTS');
$searchResult = Book::searchQuery($query)->execute();
timeZone
is used to convert date values in the query to UTC:
$query = Query::range()
->field('updated_at')
->gt('2020-10-18')
->timeZone('+01:00');
$searchResult = Book::searchQuery($query)->execute();
You can use Elastic\ScoutDriverPlus\Support\Query::regexp()
to build a query that matches documents, which
contain terms corresponding to regular expression:
$query = Query::regexp()
->field('title')
->value('b.*k');
$searchResult = Book::searchQuery($query)->execute();
Available methods:
caseInsensitive
is used to allow case insensitive matching:
$query = Query::regexp()
->field('title')
->value('b.*k')
->caseInsensitive(true);
$searchResult = Book::searchQuery($query)->execute();
Use field
to specify the field you wish to search:
$query = Query::regexp()
->field('title')
->value('b.*k');
$searchResult = Book::searchQuery($query)->execute();
Use flags
to enable optional operators for the regular expression:
$query = Query::regexp()
->field('title')
->value('b.*k')
->flags('ALL');
$searchResult = Book::searchQuery($query)->execute();
maxDeterminizedStates
defines the maximum number of automation states required for the query:
$query = Query::regexp()
->field('title')
->value('b.*k')
->maxDeterminizedStates(10000);
$searchResult = Book::searchQuery($query)->execute();
rewrite
is used to rewrite the query:
$query = Query::regexp()
->field('title')
->value('b.*k')
->rewrite('constant_score');
$searchResult = Book::searchQuery($query)->execute();
With value
you can define a regular expression for terms you wish to find in the provided field
:
$query = Query::regexp()
->field('title')
->value('b.*k');
$searchResult = Book::searchQuery($query)->execute();
You can use Elastic\ScoutDriverPlus\Support\Query::term()
to build a query that matches documents, which
contain an exact term in a provided field:
$query = Query::term()
->field('price')
->value(300);
$searchResult = Book::searchQuery($query)->execute();
Available methods:
boost
method allows you to decrease or increase the relevance scores of a query:
$query = Query::term()
->field('price')
->value(300)
->boost(2);
$searchResult = Book::searchQuery($query)->execute();
caseInsensitive
is used to allow ASCII case insensitive matching:
$query = Query::term()
->field('price')
->value(300)
->caseInsensitive(true);
$searchResult = Book::searchQuery($query)->execute();
Use field
to specify the field you wish to search:
$query = Query::term()
->field('price')
->value(300);
$searchResult = Book::searchQuery($query)->execute();
With value
you can define a term you wish to find in the provided field
:
$query = Query::term()
->field('price')
->value(300);
$searchResult = Book::searchQuery($query)->execute();
You can use Elastic\ScoutDriverPlus\Support\Query::terms()
to build a query that matches documents, which
contain one or more exact terms in a provided field:
$query = Query::terms()
->field('tags')
->values(['available', 'new']);
$searchResult = Book::searchQuery($query)->execute();
Available methods:
boost
method allows you to decrease or increase the relevance scores of a query:
$query = Query::terms()
->field('tags')
->values(['available', 'new'])
->boost(2);
$searchResult = Book::searchQuery($query)->execute();
Use field
to specify the field you wish to search:
$query = Query::terms()
->field('tags')
->values(['available', 'new']);
$searchResult = Book::searchQuery($query)->execute();
With value
you can define terms you wish to find in the provided field
:
$query = Query::terms()
->field('tags')
->values(['available', 'new']);
$searchResult = Book::searchQuery($query)->execute();
You can use Elastic\ScoutDriverPlus\Support\Query::wildcard()
to build a query that matches documents, which
contain terms corresponding to wildcard pattern:
$query = Elastic\ScoutDriverPlus\Support\Query::wildcard()
->field('title')
->value('bo*k');
$searchResult = Book::searchQuery($query)->execute();
Available methods:
boost
method allows you to decrease or increase the relevance scores of a query:
$query = Elastic\ScoutDriverPlus\Support\Query::wildcard()
->field('title')
->value('bo*k')
->boost(2);
$searchResult = Book::searchQuery($query)->execute();
caseInsensitive
is used to allow case insensitive matching:
$query = Elastic\ScoutDriverPlus\Support\Query::wildcard()
->field('title')
->value('bo*k')
->caseInsensitive(true);
$searchResult = Book::searchQuery($query)->execute();
Use field
to specify the field you wish to search:
$query = Elastic\ScoutDriverPlus\Support\Query::wildcard()
->field('title')
->value('bo*k');
$searchResult = Book::searchQuery($query)->execute();
rewrite
is used to rewrite the query:
$query = Elastic\ScoutDriverPlus\Support\Query::wildcard()
->field('title')
->value('bo*k')
->rewrite('constant_score');
$searchResult = Book::searchQuery($query)->execute();
With value
you can define a wildcard pattern for terms you wish to find in the provided field
:
$query = Elastic\ScoutDriverPlus\Support\Query::wildcard()
->field('title')
->value('bo*k');
$searchResult = Book::searchQuery($query)->execute();