Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multi-match query do not support match query options #462

Merged
merged 5 commits into from
Mar 15, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions lib/Elastica/Query/Match.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
* @category Xodoa
* @package Elastica
* @author F21
* @author WONG Wing Lun <[email protected]>
* @link http://www.elasticsearch.org/guide/reference/query-dsl/match-query.html
*/
class Match extends AbstractQuery
Expand Down Expand Up @@ -164,4 +165,30 @@ public function setFieldMaxExpansions($field, $maxExpansions)
{
return $this->setFieldParam($field, 'max_expansions', (int) $maxExpansions);
}

/**
* Set zero terms query
*
* If not set, default to 'none'
*
* @param string $field
* @param string $zeroTermQuery
* @return \Elastica\Query\Match
*/
public function setFieldZeroTermsQuery($field, $zeroTermQuery = 'none')
{
return $this->setFieldParam($field, 'zero_terms_query', $zeroTermQuery);
}

/**
* Set cutoff frequency
*
* @param string $field
* @param float $cutoffFrequency
* @return \Elastica\Query\Match
*/
public function setFieldCutoffFrequency($field, $cutoffFrequency)
{
return $this->setFieldParam($field, 'cutoff_frequency', $cutoffFrequency);
}
}
105 changes: 105 additions & 0 deletions lib/Elastica/Query/MultiMatch.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
* @category Xodoa
* @package Elastica
* @author Rodolfo Adhenawer Campagnoli Moraes <[email protected]>
* @author Wong Wing Lun <[email protected]>
* @link http://www.elasticsearch.org/guide/reference/query-dsl/multi-match-query.html
*/
class MultiMatch extends AbstractQuery
Expand Down Expand Up @@ -60,4 +61,108 @@ public function setTieBreaker($tieBreaker = 0.0)
{
return $this->setParam('tie_breaker', $tieBreaker);
}

/**
* Sets operator for Match Query
*
* If not set, defaults to 'or'
*
* @param string $operator
* @return \Elastica\Query\MultiMatch Current object
*/
public function setOperator($operator = 'or')
{
return $this->setParam('operator', $operator);
}

/**
* Set field minimum should match for Match Query
*
* @param int $minimumShouldMatch
* @return \Elastica\Query\Match
*/
public function setMinimumShouldMatch($minimumShouldMatch)
{
return $this->setParam('minimum_should_match', (int) $minimumShouldMatch);
}

/**
* Set zero terms query for Match Query
*
* If not set, default to 'none'
*
* @param string $zeroTermQuery
* @return \Elastica\Query\Match
*/
public function setZeroTermsQuery($zeroTermQuery = 'none')
{
return $this->setParam('zero_terms_query', $zeroTermQuery);
}

/**
* Set cutoff frequency for Match Query
*
* @param float $cutoffFrequency
* @return \Elastica\Query\Match
*/
public function setCutoffFrequency($cutoffFrequency)
{
return $this->setParam('cutoff_frequency', $cutoffFrequency);
}

/**
* Set type
*
* @param string $field
* @param string $type
* @return \Elastica\Query\Match
*/
public function setType($type)
{
return $this->setParam('type', $type);
}

/**
* Set fuzziness
*
* @param float $fuzziness
* @return \Elastica\Query\Match
*/
public function setFuzziness($fuzziness)
{
return $this->setParam('fuzziness', (float) $fuzziness);
}

/**
* Set prefix length
*
* @param int $prefixLength
* @return \Elastica\Query\Match
*/
public function setPrefixLength($prefixLength)
{
return $this->setParam('prefix_length', (int) $prefixLength);
}

/**
* Set max expansions
*
* @param int $maxExpansions
* @return \Elastica\Query\Match
*/
public function setMaxExpansions($maxExpansions)
{
return $this->setParam('max_expansions', (int) $maxExpansions);
}

/**
* Set analyzer
*
* @param string $analyzer
* @return \Elastica\Query\Match
*/
public function setAnalyzer($analyzer)
{
return $this->setParam('analyzer', $analyzer);
}
}