Download the PHP package bardex/elastic-query without Composer
On this page you can find all versions of the php package bardex/elastic-query. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download bardex/elastic-query
More information about bardex/elastic-query
Files in bardex/elastic-query
Package elastic-query
Short Description PHP query builder for ElasticSearch with fluent interface
License
Informations about the package elastic-query
PHP fluent interface for ElasticSearch. Version 2.
REQUIREMENTS
- PHP >= 5.5
- PHP Elasticsearch\Client ~2.0 or ~5.0 (only PHP >= 5.6.6)
- ElasticSearch server >= 5.0
INSTALLATION
QUICK START
USING MULTI-QUERY
You can use MultiQuery to execute multiple search queries for one request to the server. https://www.elastic.co/guide/en/elasticsearch/reference/current/search-multi-search.html
USING LISTENER FOR LOGGING
USE OF A CUSTOM HYDRATOR
AVAILABLE FILTERING METHODS (in SearchQuery)
- equal($value)
- in([$v1,$v2,...])
- less($max)
- lessOrEqual($max)
- greater($min)
- greaterOrEqual($min)
- between($min, $max)
- match($text, $operator = 'or') - full-text search
- wildcard('rosy*')
- regexp('ro.*n')
- less($dateEnd, $dateFormat)
- lessOrEqual($dateEnd, $dateFormat)
- greater($dateStart, $dateFormat)
- greaterOrEqual($dateStart, $dateFormat)
-
between($start, $end, $dateFormat)
-
exists() - field exists and not empty
- not($value) - not equal
- notIn([$v1,$v2,...])
- notBetween($min, $max)
- notMatch($text) - text not match
-
notExists() - field not exists or empty
- minScore() - filtered by min score
Also see class \Bardex\Elastic\Where.
Date format see https://www.elastic.co/guide/en/elasticsearch/reference/5.0/mapping-date-format.html
Exists filter https://www.elastic.co/guide/en/elasticsearch/reference/5.0/query-dsl-exists-query.html
Examples
SEARCH CONTEXT
A query that matches documents matching boolean combinations of other queries. It is built using one or more boolean clauses, each clause with a typed occurrence. The occurrence types are:
- must - The clause (query) must appear in matching documents and will contribute to the score.
- filter - The clause (query) must appear in matching documents. However unlike must the score of the query will be ignored. Filter clauses are executed in filter context, meaning that scoring is ignored and clauses are considered for caching.
- should - The clause (query) should appear in the matching document. If the bool query is in a query context and has a must or filter clause then a document will match the bool query even if none of the should queries match. In this case these clauses are only used to influence the score. If the bool query is a filter context or has neither must or filter then at least one of the should queries must match a document for it to match the bool query.
By default used must context.
Also see https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-bool-query.html
Examples
FETCH SPECIFIED FIELDS
Methods select() and exclude() can be used together.
LIMIT FETCH DOCUMENTS
SORT DOCUMENTS
USING SCRIPT-FIELDS
Also see https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-script-fields.html
Method searchQuery::fetchAll() merge script fields with fields of documents.
Use documents values and script params.
Also see:
https://www.elastic.co/guide/en/elasticsearch/reference/current/modules-scripting-expression.html
USING SCRIPT-FILTERS
Also see https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-script-query.html
DEBUGGING
Get prepared elastic query as php-array:
Get raw response from ElasticSearch server: