Elasticsuite: How to make a custom image attribute searchable

Created on 24 Jan 2019  路  2Comments  路  Source: Smile-SA/elasticsuite

I added a custom Media Image attribute. How can I make that searchable?

Preconditions

smile/elasticsuite                                2.6.4                  
magento/product-community-edition                 2.2.6

Steps to reproduce

  1. Go to product attributes
  2. add attribute of type "Media image" code my_image
  3. it's not searchable
  4. I want to create virtual category based on that image (see \Smile\ElasticsuiteCatalogRule\Model\Rule\Condition\Product\SpecialAttribute\HasImage::getSearchQuery -> changing field => 'my_image' is not working)

Expected result

I can search in my_image

Steps to solve

I found this code which says it switches the Image attribute to searchable, but actually sets is_searchable = 0 --- why is that?

https://github.com/Smile-SA/elasticsuite/blob/master/src/module-elasticsuite-catalog/Setup/CatalogSetup.php#L279-L291

question

Most helpful comment

Hello @amenk

Yes, we put the "image" to :

  • is_searchable : 0 . This prevent fulltext searching on this attribute (would have no sense to process a fulltext search on image name for most of merchants, it could probably add more noise than relevant results).

  • is_used_for_promo_rules : 1. It's kinda hacky, but attributes used for promo rules are indexed into the Elasticsearch index, and can be used to create virtual categories or optimizers rules.

Combination of these both parameters allow to have a field inside the index, but to not process fulltext search on it.

Regards

All 2 comments

Hello @amenk

Yes, we put the "image" to :

  • is_searchable : 0 . This prevent fulltext searching on this attribute (would have no sense to process a fulltext search on image name for most of merchants, it could probably add more noise than relevant results).

  • is_used_for_promo_rules : 1. It's kinda hacky, but attributes used for promo rules are indexed into the Elasticsearch index, and can be used to create virtual categories or optimizers rules.

Combination of these both parameters allow to have a field inside the index, but to not process fulltext search on it.

Regards

maybe that would make a good place in the function comment :-)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

markdimi picture markdimi  路  4Comments

gihovani picture gihovani  路  4Comments

susonwaiba picture susonwaiba  路  3Comments

wintermute-84 picture wintermute-84  路  4Comments

DanieliMi picture DanieliMi  路  5Comments