Commit 0608997c authored by Pavel's avatar Pavel
Browse files

updates for iqdev/search-dc

parent 5f2e0f9b
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -15,4 +15,9 @@ class BaseConfiguration implements Configuration
    {
        return include __DIR__.'/product.mappings.php';
    }

    public function getSettings(): array
    {
        return include __DIR__.'/product.settings.php';
    }
}
+23 −0
Original line number Diff line number Diff line
<?php

namespace IQDEV\ElasticSearch\Config;

use IQDEV\ElasticSearch\Configuration;

class MappingValidator
{
    /**
     * Проверка существовая поля в описании индекса
     *
     * @param Configuration $configuration
     * @param string $property
     *
     * @return bool
     */
    public static function isPropertyExists(Configuration $configuration, string $property): bool
    {
        $properties = array_keys($configuration->getMapping()['properties'] ?? []);

        return in_array($property, $properties, true);
    }
}
+23 −10
Original line number Diff line number Diff line
@@ -9,10 +9,23 @@ return [
        'full_search_content' => [
            'type' => 'text',
        ],
        'suggest_search_content' => [
            'type' => 'text',
            'analyzer' => 'autocomplete',
            'search_analyzer' => 'standard',
        ],
        'category_id' => [
            'type' => 'keyword',
            'index' => false,
        ],
        'rating' => [
            'type' => 'double',
            'index' => false,
        ],
        'popular' => [
            'type' => 'double',
            'index' => false,
        ],
        'search_data' => [
            'type' => 'nested',
            'properties' => [
@@ -26,7 +39,7 @@ return [
                        'facet_value' => [
                            'type' => 'keyword',
                            'index' => true
                        ],
                        ]
                    ]
                ],
                'number_facet' => [
+64 −0
Original line number Diff line number Diff line
<?php

return [
    'index' => [
        'analysis' => [
            'char_filter' => [
                'eCharFilter' => [
                    'type' => 'mapping',
                    'mappings' => [
                        'Ё=>Е',
                        'ё=>е',
                        ',=>.',
                    ]
                ]
            ],
            'analyzer' => [
                'search_analyzer' => [
                    'type' => 'custom',
                    'tokenizer' => 'standard',
                    'filter' => [
                        'lowercase',
                        'russian_stemmer',
                        'russian_stop',
                        'synonym_filter',
                        'shingle',
                    ],
                    'char_filter' => ['eCharFilter']
                ],
                'autocomplete' => [
                    'type' => 'custom',
                    'tokenizer' => 'standard',
                    'filter' => [
                        'lowercase',
                        'autocomplete_filter'
                    ]
                ]
            ],
            'filter' => [
                'shingle' => [
                    'type' => 'shingle',
                    'min_shingle_size' => 2,
                    'max_shingle_size' => 3
                ],
                'russian_stop' => [
                    'type' => 'stop',
                ],
                'russian_stemmer' => [
                    'type' => 'stemmer',
                    'language' => 'russian'
                ],
                'synonym_filter' => [
                    'type' => 'synonym_graph',
                    'expand' => false,
                    'synonyms' => []
                ],
                'autocomplete_filter' => [
                    'type' => 'edge_ngram',
                    'min_gram' => 1,
                    'max_gram' => 10,
                ]
            ]
        ],
    ]
];
 No newline at end of file
+3 −1
Original line number Diff line number Diff line
@@ -7,4 +7,6 @@ interface Configuration
    public function getIndexName(): string;

    public function getMapping(): array;

    public function getSettings(): array;
}
Loading