Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'remotes/upstream/5.x'
- Loading branch information
Showing
47 changed files
with
474 additions
and
140 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# MatchPhrase Query | ||
|
||
> More info about match phrase query is in the [official elasticsearch docs][1] | ||
The match_phrase query analyzes the text and creates a phrase query out of the analyzed text. For example: | ||
|
||
## Simple example | ||
|
||
```JSON | ||
{ | ||
"query": { | ||
"match_phrase" : { | ||
"message" : { | ||
"query" : "this is a test", | ||
"analyzer" : "my_analyzer" | ||
} | ||
} | ||
} | ||
} | ||
``` | ||
|
||
In DSL: | ||
|
||
```php | ||
$query = new MatchPhraseQuery('message', 'this is a test'); | ||
$query->addParameter('analyzer', 'my_analyzer'); | ||
|
||
$search = new Search(); | ||
$search->addQuery($query); | ||
|
||
$queryArray = $search->toArray(); | ||
``` | ||
|
||
[1]: https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-match-query-phrase.html |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# Match Phrase Prefix Query | ||
|
||
> More info about match phrase prefix query is in the [official elasticsearch docs][1] | ||
The `match_phrase_prefix` is the same as `match_phrase`, except that it allows for prefix matches on the last term in the text. For example | ||
|
||
## Simple example | ||
|
||
```JSON | ||
{ | ||
"query": { | ||
"match_phrase_prefix" : { | ||
"message" : { | ||
"query" : "quick brown f", | ||
"max_expansions" : 10 | ||
} | ||
} | ||
} | ||
} | ||
``` | ||
|
||
In DSL: | ||
|
||
```php | ||
$query = new MatchPhrasePrefixQuery('message', 'quick brown f'); | ||
$query->addParameter('max_expansions', 10); | ||
|
||
$search = new Search(); | ||
$search->addQuery($query); | ||
|
||
$queryArray = $search->toArray(); | ||
``` | ||
|
||
[1]: https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-match-query-phrase-prefix.html |
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
# Geo Bounding Box Query | ||
|
||
> More info about geo bounding box query is in the [official elasticsearch docs][1] | ||
A query allowing to filter hits based on a point location using a bounding box. Assuming the following indexed document: | ||
|
||
## Simple example | ||
|
||
```JSON | ||
{ | ||
"query": { | ||
"bool" : { | ||
"must" : { | ||
"match_all" : {} | ||
}, | ||
"filter" : { | ||
"geo_bounding_box" : { | ||
"pin.location" : { | ||
"top_left" : { | ||
"lat" : 40.73, | ||
"lon" : -74.1 | ||
}, | ||
"bottom_right" : { | ||
"lat" : 40.01, | ||
"lon" : -71.12 | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
``` | ||
|
||
In DSL: | ||
|
||
```php | ||
$search = new Search(); | ||
$location = [ | ||
['lat' => 40.73, 'lon' => -74.1], | ||
[ 'lat' => 40.01, 'lon' => -71.12], | ||
]; | ||
$boolQuery = new BoolQuery(); | ||
$boolQuery->add(new MatchAllQuery()); | ||
$geoQuery = new GeoBoundingBoxQuery('pin.location', $location); | ||
$boolQuery->add($geoQuery, BoolQuery::FILTER); | ||
$search->addQuery($boolQuery); | ||
|
||
$queryArray = $search->toArray(); | ||
``` | ||
|
||
> This query accepts an array with either 2 or 4 elements as its second parameter, | ||
failing to meet this criteria will result in an error! | ||
|
||
Alternatively the vertices of the bounding box can be set separately: | ||
|
||
```json | ||
|
||
{ | ||
"query": { | ||
"bool" : { | ||
"must" : { | ||
"match_all" : {} | ||
}, | ||
"filter" : { | ||
"geo_bounding_box" : { | ||
"pin.location" : { | ||
"top" : 40.73, | ||
"left" : -74.1, | ||
"bottom" : 40.01, | ||
"right" : -71.12 | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
``` | ||
|
||
Now via DSL: | ||
|
||
```php | ||
|
||
$search = new Search(); | ||
$location = [40.73, -74.1, 40.01, -71.12]; | ||
$boolQuery = new BoolQuery(); | ||
$boolQuery->add(new MatchAllQuery()); | ||
$geoQuery = new GeoBoundingBoxQuery('pin.location', $location); | ||
$boolQuery->add($geoQuery, BoolQuery::FILTER); | ||
$search->addQuery($boolQuery); | ||
|
||
$queryArray = $search->toArray(); | ||
|
||
``` | ||
|
||
[1]: https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-geo-bounding-box-query.html |
Oops, something went wrong.