Exemplo n.º 1
0
 /**
  * {@inheritDoc}
  */
 public function buildQuery(QueryInterface $query)
 {
     $fields = [];
     foreach ($query->getFields() as $field => $weight) {
         $fields[] = sprintf("%s^%s", $field, $weight);
     }
     $searchQueryParams = ['query' => $query->getQueryText(), 'fields' => $fields, 'minimum_should_match' => $query->getMinimumShouldMatch(), 'tie_breaker' => $query->getTieBreaker(), 'boost' => $query->getBoost()];
     if ($query->getMatchType()) {
         $searchQueryParams['type'] = $query->getMatchType();
     }
     if ($query->getCutoffFrequency()) {
         $searchQueryParams['cutoff_frequency'] = $query->getCutoffFrequency();
     }
     if ($query->getFuzzinessConfiguration()) {
         $searchQueryParams['fuzziness'] = $query->getFuzzinessConfiguration()->getValue();
         $searchQueryParams['prefix_length'] = $query->getFuzzinessConfiguration()->getPrefixLength();
         $searchQueryParams['max_expansions'] = $query->getFuzzinessConfiguration()->getMaxExpansion();
     }
     return ['multi_match' => $searchQueryParams];
 }
Exemplo n.º 2
0
 /**
  * {@inheritDoc}
  */
 public function buildQuery(QueryInterface $query)
 {
     $searchQueryParams = ['query' => $query->getQueryText(), 'minimum_should_match' => $query->getMinimumShouldMatch(), 'boost' => $query->getBoost()];
     return ['match' => [$query->getField() => $searchQueryParams]];
 }