-
Notifications
You must be signed in to change notification settings - Fork 9.3k
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
Magento 2 Multi Word Search #5590
Comments
Hello @ednacool this is by design. We've change our search in Magento 2 to use a full text algorithm. So what its doing is running that algorithm against the words in the search query. You'll notice that 'Radiant Tee' is the first hit as it has the highest relevance - both words match, then the other results are coming up because the engine is finding Tee in those products as well (lower relevance). Our market research indicated shoppers are looking for the most relevant results to be first, if there are extra results it's not a big deal. We understand that for some merchants this isn't desired behavior and have been looking at options to address in core. Unfortunately we haven't been able to come up with a design that covers our entire customer base as tuning the behavior is really merchant/catalog specific. If this is important to you I'd like to point out you can customize this behavior by doing an after plugin on the query interface and only show products with a certain relevance score or higher. Please note that filtering on that score is dependent on your search engine, the catalog and the queries that your customers are using. For that reason I think it would be very hard for us to find a generic solution that would work for the majority of our merchants. If anyone can suggest an approach or algorithm that would work across verticals for the majority of our merchants please share. |
Hi choukalos, Thanks for getting me back but is this possible you guys can add any method like full word search at least we have any configuration in backhand which allow to search the full word as some merchants don't won't search to give the additional results because sometimes it is confusing on client side for e.g if they are searching for Natural Oil and search result also show Natural Cream or Natural Aloevera and natural oil on 3rd page as i am doing for one of my merchant site the search result not looks good. Or is this possible for now i can allow the full text result only any extension or core file modification you can let me know But i think it should have any option in magento configuration |
Hi @ednacool the algorithm in both MySQL and Elasticsearch should return products containing 'Natural Oil' with a higher relevancy then products that only contain one of those words. So you should see Natural Oil on the 1st page right at the top with Natural Cream or Natural Aloevera lower in the search results. Note that our search algorithm looks at several product fields and has a weighting on those fields. There were cases where catalogs had query terms in the description multiple times and it was bringing those to the top rather then products with those query terms in the product name or sku. If that's the case for your catalog you can tune the weighting that search uses for those fields. To do that look Stores/Attributes/Product ; then filter for the searchable attribute. You can click onto each of those attributes and check the storefront properties tab; look at the search weight field. That's the one you'd adjust on a scale of 1-10 to change behavior ( note you have to do a full reindex of the full text search index to make the change happen ). At some point we'll update the old data grid to the new style and you'll be able to just add the search weight attribute to the grid display but we haven't gotten to that yet so it's a little buried. I believe name has weight 5, and sku weight 6 with description weight 1 ( along with most other attributes ). In our research that seemed to work the best for search accuracy for example data we had + advice from search experts (by the way big props to RocketWeb, Smile, Phoenix Media, and the eBay search team for all their help!). So I think at most, for out of the box, you'd just have to tune the attributes and you should get the multi-word query matches at the top of the results. More nuanced, but easy would be introducing a search filtering plugins that's specific to a search engine - that should be a fairly simple job for an extension developer. More complex would be to substitute your own search algorithm; likely that'd be tied to the search engine and would require a bit more work to get right. If you'd like to discuss further please feel free to email me (email address in profile) and we can setup a time to chat more. At this point though I'm going to close the issue as this is as designed and call out the opportunity for extension developers! |
Hi @choukalos I think the search is not working as you described, and it became a problem. I have a clean installation of 2.1.0, when I search for "abc 999" here as you can see the product with both words was on the second: http://m2-demo.mgt4.iggo.fi/catalogsearch/result/?q=abc+999 And it's second because there're not so many products, if there're many and that product was created late (=big product id), I'd bet it would be in a very late position. Because we're facing this problem in our real project, product which matches the best was put on the 4th/5th page in the search result, this is quite annoying. |
Hi, The search behaviour seems to be like @cuiyang000 described. I have products showing at the end of the list which should be positioned at the beginning according to @choukalos and it's causing a huge problem for some merchants. |
In case anyone is looking for solution for this issue: To switch OR logic to AND for search query, add etc/search_request.xml file in your local module with the following content:
Also, in your local module's etc/module.xml file add the following dependency:
I hope it will help someone. I spent a lot of time on digging it :-). |
hi @ednacool Can you tell me how to fix it? |
@michalbiarda |
Hi @AliPs94, please try reading this tutorial first or devdocs for a jump start on module development. |
@korostii |
@AliPs94 |
@gerben86 @korostii @michalbiarda Apparently, the entire request object is needed.
This is because the XML validator requires multiple elements in each |
This works on Magento 2.2.2 |
I implemnented the above (michalbiarda). It works. However for every keyword that a search synonym exists for NO results wll be found any longer. It seems like the adapted query now searches for products that matches 'keyword' AND 'synonym' => which ofcourse will never give any result. Any solution? |
@michalbiarda @nathanmerrill - any comment? |
any solution , guys ? |
Yes this works but do you know how to add other attributes besides sku. I have some products with multiple cross references and the hyphens are constantly throwing no search results. |
Hi, I noticed it mentioned there was market research and that "if there are extra results it's not a big deal." Can somebody point me to that research? Everyone we have test our magento site complains they see a bunch of random search results. If the first few results are correct it doesn't seem to help, they see the rest and think they're way off base with their search criteria. I can't imagine search working well without it being a filtering mechanism. Imagine a customer trying to add the color of item they want into the search text, they'll be looking at everything of that color rather than filtering down their current results. This search mechanism out of the box is undeniably counterintuitive. |
Any Solutions ? |
I had same situation and i was using my own code I could not override the other interceptors for synonyms as it was becoming huge mess to edit whole chain of functions for this purpose. If search term is "gold necklace", the AND based search query is "+gold* +necklace*" Expected search term is (gold and necklace)OR(gold and pendant) |
Did anyone found proper solution to fix this issue? |
Search is working weird as it is not giving the proper result by matching whole word for e.g if i search for
Radiant Tee it is giving other results too. You can check it out in given link
http://magento2demo.firebearstudio.com/catalogsearch/result/?q=Radiant+Tee+
Seems to be search feature needs fixing
The text was updated successfully, but these errors were encountered: