38 $this->fieldMapper = $fieldMapper;
45 public function build(array $selectQuery, RequestQueryInterface $requestQuery, $conditionType)
47 $queryValue = $this->
prepareQuery($requestQuery->getValue(), $conditionType);
48 $queries = $this->
buildQueries($requestQuery->getMatches(), $queryValue);
49 $requestQueryBoost = $requestQuery->getBoost() ?: 1;
50 foreach ($queries as
$query) {
51 $queryBody =
$query[
'body'];
52 $matchKey = isset($queryBody[
'match_phrase']) ?
'match_phrase' :
'match';
53 foreach ($queryBody[$matchKey] as $field => $matchQuery) {
54 $matchQuery[
'boost'] = $requestQueryBoost + $matchQuery[
'boost'];
55 $queryBody[$matchKey][$field] = $matchQuery;
57 $selectQuery[
'bool'][
$query[
'condition']][] = $queryBody;
70 $queryValue = $this->
escape($queryValue);
71 foreach ($this->preprocessorContainer as $preprocessor) {
72 $queryValue = $preprocessor->process($queryValue);
74 $condition = $conditionType === BoolExpression::QUERY_CONDITION_NOT ?
77 'condition' => $condition,
78 'value' => $queryValue,
102 $value = preg_replace(
'#^\\\\"(.*)\\\\"$#m',
'$1', $queryValue[
'value'], -1,
$count);
103 $condition = (
$count) ?
'match_phrase' :
'match';
105 foreach ($matches as $match) {
106 $resolvedField = $this->fieldMapper->getFieldName(
108 [
'type' => FieldMapperInterface::TYPE_QUERY]
111 'condition' => $queryValue[
'condition'],
116 'boost' => isset($match[
'boost']) ? $match[
'boost'] : 1,
139 $pattern =
'/(\+|-|&&|\|\||!|\(|\)|\{|}|\[|]|\^|"|~|\*|\?|:|\\\)/';
__construct(FieldMapperInterface $fieldMapper, array $preprocessorContainer)
buildQueries(array $matches, array $queryValue)
const QUERY_CONDITION_MUST_NOT
prepareQuery($queryValue, $conditionType)
build(array $selectQuery, RequestQueryInterface $requestQuery, $conditionType)