Hello.
I've just discovered we could pretty easily get support for synonyms with small modification of indexer.
As I am not really Magento's developer I decided to prepare all knowledge needed to prepare this feature here.
To add synonyms support for ES Index we have to send PUT /indexName request to Elasticsearch. Payload should looke like:
a) For Elasticsearch 5.x:
As you might see payload is really similar expect synonym block inside filter block. Above, we have example with external file with synonyms in Solr format. Obviously, we should be able to inline synonyms. For that, we just modify synonym block (it is universal version for 5.x & 7.x):
We should sign it is better to use the external file. However, it is recommended to define large synonyms set in a file using synonyms_path, because specifying them inline increases cluster size unnecessarily. - from ES docs.
synonyms_path has a base in /etc/elasticsearch.
Todo list
New tab in Indexer's settings called Synonyms
[ ] Select field allowing choose Elasticsearch Version
[ ] Select field allowing choose between Inline synonyms or External File with synonyms
[ ] Textarea field if we chose Inline synonyms
[ ] Text input with path to External file. I believe it should be done this way (no with uploading a file) because I bet Elasticsearch will try to resolve path in own scope (/etc/elasticsearch). Moreover, VSF-Api with ES could be even on different machine.
[ ] Show some information it is better to use External file way
[ ] After we configure it, Indexer should send PUT request (as described above) at the beginning full reindex. I am not sure if you should extend module-vsbridge-indexer-catalog/Index/Mapping/Product.php or create whole new Abstraction for Settings as we have for Mappings.
Based on Elasticsearch documentation, after we PUT these analyzer's settings - synonyms should work - no need for changes in PWA.
Hello. I've just discovered we could pretty easily get support for synonyms with small modification of indexer. As I am not really Magento's developer I decided to prepare all knowledge needed to prepare this feature here.
To add synonyms support for ES Index we have to send PUT /indexName request to Elasticsearch. Payload should looke like: a) For Elasticsearch 5.x:
b) For Elasticsearch 7.x:
As you might see payload is really similar expect
synonym
block insidefilter
block. Above, we have example with external file with synonyms in Solr format. Obviously, we should be able to inline synonyms. For that, we just modifysynonym
block (it is universal version for 5.x & 7.x):We should sign it is better to use the external file.
However, it is recommended to define large synonyms set in a file using synonyms_path, because specifying them inline increases cluster size unnecessarily.
- from ES docs.synonyms_path has a base in
/etc/elasticsearch
.Todo list
Inline synonyms
External file way
module-vsbridge-indexer-catalog/Index/Mapping/Product.php
or create whole new Abstraction for Settings as we have for Mappings.Based on Elasticsearch documentation, after we PUT these analyzer's settings - synonyms should work - no need for changes in PWA.
Synonyms' docs: Elasticsearch 5.x: https://www.elastic.co/guide/en/elasticsearch/reference/5.5/analysis-synonym-tokenfilter.html Elasticsearch 7.x: https://www.elastic.co/guide/en/elasticsearch/reference/current/analysis-synonym-tokenfilter.html