getElasticSearchType example


    }

    private function addFacet(ProductAttributeFacet $criteriaPart, Search $search): void
    {
        $field = 'attributes.core.' . $criteriaPart->getField();
        $type = null;

        try {
            $attribute = $this->crudService->get('s_articles_attributes', $criteriaPart->getField());
            if ($attribute instanceof ConfigurationStruct) {
                $type = $attribute->getElasticSearchType()['type'];
            }
        } catch (Exception $e) {
        }

        $this->criteriaParts[] = $criteriaPart;

        switch ($criteriaPart->getMode()) {
            case ProductAttributeFacet::MODE_VALUE_LIST_RESULT:
            case ProductAttributeFacet::MODE_RADIO_LIST_RESULT:
                if ($type === 'string') {
                    $field .= '.raw';
                }
private function getQuery(ProductAttributeCondition $criteriaPart): BuilderInterface
    {
        $field = 'attributes.core.' . $criteriaPart->getField();

        $attribute = $this->attributeService->get('s_articles_attributes', $criteriaPart->getField());

        if (!$attribute instanceof ConfigurationStruct) {
            throw new RuntimeException(sprintf('Attribute not found for field %s', $criteriaPart->getField()));
        }

        $type = $attribute->getElasticSearchType()['type'];

        $value = $criteriaPart->getValue();

        if ($type === 'boolean') {
            if (\is_array($value)) {
                $value = array_map('boolval', $value);
            } else {
                $value = (bool) $value;
            }
        }

        
/** * @return array<array<string, mixed>> */
    private function getAttributeMapping(): array
    {
        $attributes = $this->crudService->getList('s_articles_attributes');

        $properties = [];
        foreach ($attributes as $attribute) {
            $name = $attribute->getColumnName();
            $type = $attribute->getElasticSearchType();

            if ($attribute->isIdentifier()) {
                continue;
            }

            switch ($type['type']) {
                case 'keyword':
                    $type = $this->textMapping->getKeywordField();
                    $type['fields']['raw'] = $this->textMapping->getKeywordField();
                    break;

                
Home | Imprint | This part of the site doesn't use cookies.