File tree Expand file tree Collapse file tree 1 file changed +49
-0
lines changed
Expand file tree Collapse file tree 1 file changed +49
-0
lines changed Original file line number Diff line number Diff line change 1+ <?php declare (strict_types = 1 );
2+
3+ namespace Spameri \ElasticQuery \Query ;
4+
5+ class PhrasePrefix implements \Spameri \ElasticQuery \Query \LeafQueryInterface
6+ {
7+
8+ private string $ field ;
9+
10+ private string $ queryString ;
11+
12+ private int $ boost ;
13+
14+ private int $ slop ;
15+
16+
17+ public function __construct (
18+ string $ field ,
19+ string $ queryString ,
20+ int $ boost = 1 ,
21+ int $ slop = 1
22+ ) {
23+ $ this ->field = $ field ;
24+ $ this ->queryString = $ queryString ;
25+ $ this ->boost = $ boost ;
26+ $ this ->slop = $ slop ;
27+ }
28+
29+
30+ public function key (): string
31+ {
32+ return 'phrase_prefix_ ' . $ this ->field . '_ ' . $ this ->queryString ;
33+ }
34+
35+
36+ public function toArray (): array
37+ {
38+ return [
39+ 'match_phrase_prefix ' => [
40+ $ this ->field => [
41+ 'query ' => $ this ->queryString ,
42+ 'boost ' => $ this ->boost ,
43+ 'slop ' => $ this ->slop ,
44+ ],
45+ ],
46+ ];
47+ }
48+
49+ }
You can’t perform that action at this time.
0 commit comments