Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[2.x] Use synonym graph instead of regular synonyms #663

Merged
merged 1 commit into from
Nov 28, 2024

Conversation

Jade-GG
Copy link
Collaborator

@Jade-GG Jade-GG commented Nov 28, 2024

The difference between the two is here in the documentation: https://www.elastic.co/guide/en/elasticsearch/reference/7.17/analysis-synonym-graph-tokenfilter.html

But in short, this allows you to use synonyms that are multiple words without those words getting broken up into individual tokens. For clarity, here's an example.


Say you have a synonym set up with "jacket" and "large shirt". Before this change, that turned searches for "jacket" to also search for "large" and "shirt" individually, returning anything large and your whole stock of shirts. Not really ideal for when you're trying to sell people jackets!

After this change, the "large shirt" automatically gets turned into a phrase where both words must exist before it matches. Thus, your search will correctly only return jackets and large shirts, which is more in line with what you would expect.


We could also make this configurable, however I currently don't really see a world where you want the other behavior.

@royduin
Copy link
Member

royduin commented Nov 28, 2024

This behaviour matches how Magento handles synonyms?

@Jade-GG
Copy link
Collaborator Author

Jade-GG commented Nov 28, 2024

This behaviour matches how Magento handles synonyms?

As it turns out (I hadn't actually checked before this), yes it does! See module-elasticsearch/Model/Adapter/Index/Builder.php:

$synonymFilter = [
    'synonyms' => [
        'type' => 'synonym_graph',
        'synonyms' => $synonyms
    ]
];

@royduin royduin merged commit 6567325 into 2.x Nov 28, 2024
15 checks passed
@royduin royduin deleted the feature/2.x-synonymgraph branch November 28, 2024 12:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants