diff --git a/app/code/Magento/Elasticsearch/Model/Adapter/FieldMapper/Product/AttributeAdapter.php b/app/code/Magento/Elasticsearch/Model/Adapter/FieldMapper/Product/AttributeAdapter.php index 2d1396347270..7bc717e5796f 100644 --- a/app/code/Magento/Elasticsearch/Model/Adapter/FieldMapper/Product/AttributeAdapter.php +++ b/app/code/Magento/Elasticsearch/Model/Adapter/FieldMapper/Product/AttributeAdapter.php @@ -60,6 +60,16 @@ public function isSearchable(): bool || $this->isFilterable()); } + /** + * Check if attribute value can be suggested. + * + * @return bool + */ + public function isSuggestible(): bool + { + return $this->getAttribute()->getIsSearchable(); + } + /** * Check if attribute is need to index always. * diff --git a/app/code/Magento/Elasticsearch/Model/Adapter/FieldMapper/Product/FieldProvider/StaticField.php b/app/code/Magento/Elasticsearch/Model/Adapter/FieldMapper/Product/FieldProvider/StaticField.php index b9d4c3393648..2bff1a0b3bed 100644 --- a/app/code/Magento/Elasticsearch/Model/Adapter/FieldMapper/Product/FieldProvider/StaticField.php +++ b/app/code/Magento/Elasticsearch/Model/Adapter/FieldMapper/Product/FieldProvider/StaticField.php @@ -169,6 +169,8 @@ public function getField(AbstractAttribute $attribute): array ]; } + $fieldMapping[$fieldName]['suggestible'] = $attributeAdapter->isSuggestible(); + if ($attributeAdapter->isTextType()) { $keywordFieldName = FieldTypeConverterInterface::INTERNAL_DATA_TYPE_KEYWORD; $index = $this->indexTypeConverter->convert( @@ -207,6 +209,7 @@ public function getField(AbstractAttribute $attribute): array 'normalizer' => 'folding', ]; } + $fieldMapping[$childFieldName]['suggestible'] = $attributeAdapter->isSuggestible(); } return $fieldMapping; diff --git a/app/code/Magento/Elasticsearch/Model/DataProvider/Base/Suggestions.php b/app/code/Magento/Elasticsearch/Model/DataProvider/Base/Suggestions.php index d16041eef4b5..28d429def9b7 100644 --- a/app/code/Magento/Elasticsearch/Model/DataProvider/Base/Suggestions.php +++ b/app/code/Magento/Elasticsearch/Model/DataProvider/Base/Suggestions.php @@ -282,7 +282,8 @@ private function addSuggestFields($searchQuery, $searchSuggestionsCount) private function getSuggestFields() { $fields = array_filter($this->fieldProvider->getFields(), function ($field) { - return (($field['type'] ?? null) === 'text') && (($field['index'] ?? null) !== false); + return (($field['type'] ?? null) === 'text') && (($field['index'] ?? null) !== false) + && (($field['suggestible'] ?? null) !== false); }); return array_keys($fields);