forked from ruflin/Elastica
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added Reindex and deprecated CrossIndex (ruflin#1311) (ruflin#1315)
added changelog entry and asserts to config test added SpanOrTest added SpanMulti span functions in dsl query updated removed unnecessary attributes reverted docker ip range Changelog update Changelog update
- Loading branch information
1 parent
3b111b2
commit cdd9710
Showing
14 changed files
with
932 additions
and
10 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<?php | ||
namespace Elastica\Query; | ||
|
||
use Elastica\Exception\InvalidException; | ||
|
||
/** | ||
* SpanMulti query. | ||
* | ||
* @author Marek Hernik <[email protected]> | ||
* | ||
* @link https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-span-near-query.html | ||
*/ | ||
class SpanMulti extends SpanQuery | ||
{ | ||
/** | ||
* Constructs a SpanMulti query object. | ||
* | ||
* @param AbstractQuery $match OPTIONAL | ||
*/ | ||
public function __construct(AbstractQuery $match = null) | ||
{ | ||
if ($match) { | ||
$this->setMatch($match); | ||
} | ||
} | ||
|
||
/** | ||
* Set match part to query. | ||
* | ||
* @param AbstractQuery $match | ||
* | ||
* @throws InvalidException | ||
* | ||
* @return $this | ||
*/ | ||
public function setMatch(AbstractQuery $match) | ||
{ | ||
if (!in_array(get_class($match), [Wildcard::class, Fuzzy::class, Prefix::class, Regexp::class])) { | ||
throw new InvalidException( | ||
'Invalid parameter. Has to be instance of WildcardQuery or FuzzyQuery or PrefixQuery od RegexpQuery' | ||
); | ||
} | ||
|
||
return $this->setParams(['match' => $match]); | ||
} | ||
} |
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,71 @@ | ||
<?php | ||
namespace Elastica\Query; | ||
|
||
use Elastica\Exception\InvalidException; | ||
|
||
/** | ||
* SpanNear query. | ||
* | ||
* @author Marek Hernik <[email protected]> | ||
* | ||
* @link https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-span-near-query.html | ||
*/ | ||
class SpanNear extends SpanQuery | ||
{ | ||
/** | ||
* Constructs a SpanNear query object. | ||
* | ||
* @param SpanQuery[] $clauses OPTIONAL | ||
* @param int $slop OPTIONAL maximum proximity | ||
* @param bool $inOrder OPTIONAL true if order of searched clauses is important | ||
*/ | ||
public function __construct(array $clauses = [], $slop = 1, $inOrder = false) | ||
{ | ||
if (!empty($clauses)) { | ||
foreach ($clauses as $clause) { | ||
if (!is_subclass_of($clause, SpanQuery::class)) { | ||
throw new InvalidException( | ||
'Invalid parameter. Has to be array or instance of Elastica\Query\SpanQuery' | ||
); | ||
} | ||
} | ||
} | ||
$this->setParams(['clauses' => $clauses]); | ||
$this->setSlop($slop); | ||
$this->setInOrder($inOrder); | ||
} | ||
|
||
/** | ||
* @param int $slop | ||
*/ | ||
public function setSlop($slop) | ||
{ | ||
$this->setParam('slop', $slop); | ||
} | ||
|
||
/** | ||
* @param bool $inOrder | ||
*/ | ||
public function setInOrder($inOrder) | ||
{ | ||
$this->setParam('in_order', $inOrder); | ||
} | ||
|
||
/** | ||
* Add clause part to query. | ||
* | ||
* @param SpanQuery $clause | ||
* | ||
* @throws InvalidException If not valid query | ||
* | ||
* @return $this | ||
*/ | ||
public function addClause($clause) | ||
{ | ||
if (!is_subclass_of($clause, SpanQuery::class)) { | ||
throw new InvalidException('Invalid parameter. Has to be array or instance of Elastica\Query\SpanQuery'); | ||
} | ||
|
||
return $this->addParam('clauses', $clause); | ||
} | ||
} |
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,51 @@ | ||
<?php | ||
namespace Elastica\Query; | ||
|
||
use Elastica\Exception\InvalidException; | ||
|
||
/** | ||
* SpanOr query. | ||
* | ||
* @author Marek Hernik <[email protected]> | ||
* | ||
* @link https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-span-term-query.html | ||
*/ | ||
class SpanOr extends SpanQuery | ||
{ | ||
/** | ||
* Constructs a SpanOr query object. | ||
* | ||
* @param SpanQuery[] $clauses OPTIONAL | ||
*/ | ||
public function __construct(array $clauses = []) | ||
{ | ||
if (!empty($clauses)) { | ||
foreach ($clauses as $clause) { | ||
if (!is_subclass_of($clause, SpanQuery::class)) { | ||
throw new InvalidException( | ||
'Invalid parameter. Has to be array or instance of Elastica\Query\SpanQuery' | ||
); | ||
} | ||
} | ||
} | ||
$this->setParams(['clauses' => $clauses]); | ||
} | ||
|
||
/** | ||
* Add clause part to query. | ||
* | ||
* @param SpanQuery $clause | ||
* | ||
* @throws InvalidException If not valid query | ||
* | ||
* @return $this | ||
*/ | ||
public function addClause($clause) | ||
{ | ||
if (!is_subclass_of($clause, SpanQuery::class)) { | ||
throw new InvalidException('Invalid parameter. Has to be array or instance of Elastica\Query\SpanQuery'); | ||
} | ||
|
||
return $this->addParam('clauses', $clause); | ||
} | ||
} |
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,14 @@ | ||
<?php | ||
namespace Elastica\Query; | ||
|
||
/** | ||
* Span query. | ||
* | ||
* @author Marek Hernik <[email protected]> | ||
* | ||
* @link https://www.elastic.co/guide/en/elasticsearch/reference/current/span-queries.html | ||
*/ | ||
class SpanQuery extends AbstractQuery | ||
{ | ||
|
||
} |
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,38 @@ | ||
<?php | ||
namespace Elastica\Query; | ||
|
||
/** | ||
* SpanTerm query. | ||
* | ||
* @author Marek Hernik <[email protected]> | ||
* | ||
* @link https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-span-term-query.html | ||
*/ | ||
class SpanTerm extends SpanQuery | ||
{ | ||
/** | ||
* Constructs the SpanTerm query object. | ||
* | ||
* @param string $field | ||
* @param string $value | ||
* @param float $boost OPTIONAL Boost value (default = 1) | ||
*/ | ||
public function __construct($field, $value, $boost = 1.0) | ||
{ | ||
$this->setRawTerm($field, $value, $boost); | ||
} | ||
|
||
/** | ||
* Sets the query expression for a key with its boost value. | ||
* | ||
* @param string $field | ||
* @param string $value | ||
* @param float $boost | ||
* | ||
* @return $this | ||
*/ | ||
public function setRawTerm($field, $value, $boost = 1.0) | ||
{ | ||
return $this->setParam($field, ['value' => $value, 'boost' => $boost]); | ||
} | ||
} |
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
Oops, something went wrong.