PrefixQuery example

return new TermsQuery($field$value);

            case ProductAttributeCondition::OPERATOR_STARTS_WITH:
                if (!\is_string($value)) {
                    throw new RuntimeException('Invalid value for PrefixQuery provided');
                }

                if ($type === 'string') {
                    $field .= '.raw';
                }

                return new PrefixQuery($field$value);

            case ProductAttributeCondition::OPERATOR_ENDS_WITH:
                if (\is_array($value)) {
                    throw new RuntimeException('Invalid value for WildcardQuery provided');
                }

                if ($type === 'string') {
                    $field .= '.raw';
                }

                return new WildcardQuery($field, '*' . $value);

            


    private function parsePrefixFilter(PrefixFilter $filter, EntityDefinition $definition, Context $context): BuilderInterface
    {
        $accessor = $this->buildAccessor($definition$filter->getField()$context);

        $value = $filter->getValue();

        if ($this->keyValueStorage->get(ElasticsearchIndexer::ENABLE_MULTILINGUAL_INDEX_KEY, false)) {
            $field = $this->getField($definition$filter->getField());

            $query = new PrefixQuery($accessor$value);

            if ($field instanceof TranslatedField) {
                $multiMatchFields = [];

                foreach ($context->getLanguageIdChain() as $languageId) {
                    $multiMatchFields[] = $this->getTranslatedFieldName($accessor$languageId) . '.search';
                }

                $query = new MultiMatchQuery($multiMatchFields$value[
                    'type' => 'phrase_prefix',
                    'slop' => 5,
                ]);
Home | Imprint | This part of the site doesn't use cookies.