Skip to content
Snippets Groups Projects
Unverified Commit 62f765c4 authored by Simonas Šerlinskas's avatar Simonas Šerlinskas
Browse files

Merge branch '6.x'

parents 6065d0a2 a5729780
No related branches found
No related tags found
No related merge requests found
Documentation in progress...
\ No newline at end of file
# Span Near Query
> More info about span near query is in the [official elasticsearch docs][1]
Matches spans which are near one another. One can specify slop, the maximum number of intervening unmatched positions, as well as whether matches are required to be in-order. The span near query maps to Lucene SpanNearQuery. Here is an example:
## Simple example
```JSON
{
"query": {
"span_near" : {
"clauses" : [
{ "span_term" : { "field" : "value1" } },
{ "span_term" : { "field" : "value2" } },
{ "span_term" : { "field" : "value3" } }
],
"slop" : 12,
"in_order" : false
}
}
}
```
In DSL:
```php
$search = new Search();
$spanNearQuery = new SpanNearQuery();
$spanNearQuery->addQuery(new SpanTermQuery('field', 'value1'));
$spanNearQuery->addQuery(new SpanTermQuery('field', 'value2'));
$spanNearQuery->addQuery(new SpanTermQuery('field', 'value3'));
$spanNearQuery->addParameter('slop', 12);
$spanNearQuery->addParameter('in_order', false);
$search->addQuery($spanNearQuery);
$queryArray = $search->toArray();
```
[1]: https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-span-near-query.html
......@@ -43,7 +43,7 @@ class BuilderBag
if (method_exists($builder, 'getName')) {
$name = $builder->getName();
} else {
$name = uniqid();
$name = bin2hex(random_bytes(30));
}
$this->bag[$name] = $builder;
......
......@@ -67,4 +67,24 @@ class NestedQuery implements BuilderInterface
)
];
}
/**
* Returns nested query object.
*
* @return BuilderInterface
*/
public function getQuery()
{
return $this->query;
}
/**
* Returns path this query is set for.
*
* @return string
*/
public function getPath()
{
return $this->path;
}
}
......@@ -663,6 +663,8 @@ class Search
'lenient',
'explain',
'_source',
'_source_exclude',
'_source_include',
'stored_fields',
'sort',
'track_scores',
......
......@@ -37,7 +37,7 @@ abstract class AbstractSearchEndpoint extends AbstractNormalizable implements Se
}
if (!$key) {
$key = uniqid();
$key = bin2hex(random_bytes(30));
}
$this->container[$key] = $builder;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment