Loading src/ElasticSearch/Config/BaseConfiguration.php +6 −1 Original line number Diff line number Diff line Loading @@ -15,4 +15,9 @@ class BaseConfiguration implements Configuration { return include __DIR__.'/product.mappings.php'; } public function getSettings(): array { return include __DIR__.'/product.settings.php'; } } src/ElasticSearch/Config/MappingValidator.php 0 → 100644 +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); } } src/ElasticSearch/Config/product.mappings.php +23 −10 Original line number Diff line number Diff line Loading @@ -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' => [ Loading @@ -26,7 +39,7 @@ return [ 'facet_value' => [ 'type' => 'keyword', 'index' => true ], ] ] ], 'number_facet' => [ Loading src/ElasticSearch/Config/product.settings.php 0 → 100644 +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 src/ElasticSearch/Configuration.php +3 −1 Original line number Diff line number Diff line Loading @@ -7,4 +7,6 @@ interface Configuration public function getIndexName(): string; public function getMapping(): array; public function getSettings(): array; } Loading
src/ElasticSearch/Config/BaseConfiguration.php +6 −1 Original line number Diff line number Diff line Loading @@ -15,4 +15,9 @@ class BaseConfiguration implements Configuration { return include __DIR__.'/product.mappings.php'; } public function getSettings(): array { return include __DIR__.'/product.settings.php'; } }
src/ElasticSearch/Config/MappingValidator.php 0 → 100644 +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); } }
src/ElasticSearch/Config/product.mappings.php +23 −10 Original line number Diff line number Diff line Loading @@ -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' => [ Loading @@ -26,7 +39,7 @@ return [ 'facet_value' => [ 'type' => 'keyword', 'index' => true ], ] ] ], 'number_facet' => [ Loading
src/ElasticSearch/Config/product.settings.php 0 → 100644 +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
src/ElasticSearch/Configuration.php +3 −1 Original line number Diff line number Diff line Loading @@ -7,4 +7,6 @@ interface Configuration public function getIndexName(): string; public function getMapping(): array; public function getSettings(): array; }