Skip to content

Commit a572978

Browse files
author
Simonas Šerlinskas
committed
Merge remote-tracking branch '5.x' into 6.x
# Conflicts: # composer.json
2 parents e4df29d + 170b7e6 commit a572978

File tree

5 files changed

+64
-3
lines changed

5 files changed

+64
-3
lines changed

Diff for: docs/Query/Span/SpanNear.md

+40-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,40 @@
1-
Documentation in progress...
1+
# Span Near Query
2+
3+
> More info about span near query is in the [official elasticsearch docs][1]
4+
5+
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:
6+
7+
## Simple example
8+
9+
```JSON
10+
{
11+
"query": {
12+
"span_near" : {
13+
"clauses" : [
14+
{ "span_term" : { "field" : "value1" } },
15+
{ "span_term" : { "field" : "value2" } },
16+
{ "span_term" : { "field" : "value3" } }
17+
],
18+
"slop" : 12,
19+
"in_order" : false
20+
}
21+
}
22+
}
23+
```
24+
25+
In DSL:
26+
27+
```php
28+
$search = new Search();
29+
$spanNearQuery = new SpanNearQuery();
30+
$spanNearQuery->addQuery(new SpanTermQuery('field', 'value1'));
31+
$spanNearQuery->addQuery(new SpanTermQuery('field', 'value2'));
32+
$spanNearQuery->addQuery(new SpanTermQuery('field', 'value3'));
33+
$spanNearQuery->addParameter('slop', 12);
34+
$spanNearQuery->addParameter('in_order', false);
35+
$search->addQuery($spanNearQuery);
36+
37+
$queryArray = $search->toArray();
38+
```
39+
40+
[1]: https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-span-near-query.html

Diff for: src/BuilderBag.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public function add(BuilderInterface $builder)
4343
if (method_exists($builder, 'getName')) {
4444
$name = $builder->getName();
4545
} else {
46-
$name = uniqid();
46+
$name = bin2hex(random_bytes(30));
4747
}
4848

4949
$this->bag[$name] = $builder;

Diff for: src/Query/Joining/NestedQuery.php

+20
Original file line numberDiff line numberDiff line change
@@ -67,4 +67,24 @@ public function toArray()
6767
)
6868
];
6969
}
70+
71+
/**
72+
* Returns nested query object.
73+
*
74+
* @return BuilderInterface
75+
*/
76+
public function getQuery()
77+
{
78+
return $this->query;
79+
}
80+
81+
/**
82+
* Returns path this query is set for.
83+
*
84+
* @return string
85+
*/
86+
public function getPath()
87+
{
88+
return $this->path;
89+
}
7090
}

Diff for: src/Search.php

+2
Original file line numberDiff line numberDiff line change
@@ -663,6 +663,8 @@ public function addUriParam($name, $value)
663663
'lenient',
664664
'explain',
665665
'_source',
666+
'_source_exclude',
667+
'_source_include',
666668
'stored_fields',
667669
'sort',
668670
'track_scores',

Diff for: src/SearchEndpoint/AbstractSearchEndpoint.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public function add(BuilderInterface $builder, $key = null)
3737
}
3838

3939
if (!$key) {
40-
$key = uniqid();
40+
$key = bin2hex(random_bytes(30));
4141
}
4242

4343
$this->container[$key] = $builder;

0 commit comments

Comments
 (0)