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

Magento 2.2.6 Searching for product with dash doesn't work #21059

Closed
Luuk-Meijer opened this issue Feb 8, 2019 · 40 comments
Closed

Magento 2.2.6 Searching for product with dash doesn't work #21059

Luuk-Meijer opened this issue Feb 8, 2019 · 40 comments
Labels
Component: CatalogSearch Issue: Clear Description Gate 2 Passed. Manual verification of the issue description passed Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed Reproduced on 2.3.x The issue has been reproduced on latest 2.3 release

Comments

@Luuk-Meijer
Copy link

Preconditions (*)

  1. Magento 2 version 2.2.6

Steps to reproduce (*)

  1. In "vendor/magento/module-catalog-search/etc/search_request.xml" change
<query xsi:type="boolQuery" name="quick_search_container" boost="1">
    <queryReference clause="should" ref="search" />
    <queryReference clause="must" ref="category"/>
    <queryReference clause="must" ref="price"/>
    <queryReference clause="must" ref="visibility"/>
</query>

to

<query xsi:type="boolQuery" name="quick_search_container" boost="1">
    <queryReference clause="must" ref="search" />
    <queryReference clause="must" ref="category"/>
    <queryReference clause="must" ref="price"/>
    <queryReference clause="must" ref="visibility"/>
</query>

So that the search query "blue boot" only shows products with both the words.
2. Add a product in the back-end with a name with a dash (-) in the name.
For instance "Lakboot Black Mat New A-327 N118" in my case
3. On the frontend search for that product.
So with my example you would search for "A-327".
4. Now when you have the search clause for must nothing is going to show up.

Expected result (*)

  1. You would expect the product to show up

Actual result (*)

  1. There are no results found
@magento-engcom-team
Copy link
Contributor

Hi @DeLuuk. Thank you for your report.
To help us process this issue please make sure that you provided the following information:

  • Summary of the issue
  • Information on your environment
  • Steps to reproduce
  • Expected and actual results

Please make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, please, add a comment to the issue:

@magento-engcom-team give me 2.3-develop instance - upcoming 2.3.x release

For more details, please, review the Magento Contributor Assistant documentation.

@DeLuuk do you confirm that you was able to reproduce the issue on vanilla Magento instance following steps to reproduce?

  • yes
  • no

@magento-engcom-team magento-engcom-team added the Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed label Feb 8, 2019
@Luuk-Meijer
Copy link
Author

@magento-engcom-team I can't reproduce this on a vanilla instance since the "vendor/magento/module-catalog-search/etc/search_request.xml" needs to be changed first.

I know that that would maybe mean it isn't a vanilla bug but in my opinion editing that clause should be possible and should work.

@ghost ghost self-assigned this Feb 8, 2019
@magento-engcom-team
Copy link
Contributor

Hi @engcom-backlog-nazar. Thank you for working on this issue.
In order to make sure that issue has enough information and ready for development, please read and check the following instruction: 👇

  • 1. Verify that issue has all the required information. (Preconditions, Steps to reproduce, Expected result, Actual result).

    DetailsIf the issue has a valid description, the label Issue: Format is valid will be added to the issue automatically. Please, edit issue description if needed, until label Issue: Format is valid appears.

  • 2. Verify that issue has a meaningful description and provides enough information to reproduce the issue. If the report is valid, add Issue: Clear Description label to the issue by yourself.

  • 3. Add Component: XXXXX label(s) to the ticket, indicating the components it may be related to.

  • 4. Verify that the issue is reproducible on 2.3-develop branch

    Details- Add the comment @magento-engcom-team give me 2.3-develop instance to deploy test instance on Magento infrastructure.
    - If the issue is reproducible on 2.3-develop branch, please, add the label Reproduced on 2.3.x.
    - If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and stop verification process here!

  • 5. Verify that the issue is reproducible on 2.2-develop branch.

    Details- Add the comment @magento-engcom-team give me 2.2-develop instance to deploy test instance on Magento infrastructure.
    - If the issue is reproducible on 2.2-develop branch, please add the label Reproduced on 2.2.x

  • Next steps are available in case you are a member of Community Maintainers.

  • 6. Add label Issue: Confirmed once verification is complete.

  • 7. Make sure that automatic system confirms that report has been added to the backlog.

@ghost
Copy link

ghost commented Feb 8, 2019

HI @DeLuuk thank you for you report, this will fixed by this pr -> #20727

@ghost ghost closed this as completed Feb 8, 2019
@ghost
Copy link

ghost commented Feb 8, 2019

@DeLuuk

After changing any of these options, rebuild your FULLTEXT indexes for the change to take effect. For example, to make two-character words searchable, you could put the following lines in an option file:

[mysqld]
innodb_ft_min_token_size=2
ft_min_word_len=2

https://dev.mysql.com/doc/refman/8.0/en/fulltext-fine-tuning.html

@Luuk-Meijer
Copy link
Author

@magento-engcom-team thanks for linking other issue but Im still having trouble.

I want to be able to search for "A-327" not just "A-".
I haven't edited my option file yet, don't even know where that file is, but even if I do I dont think that would fix my problem.

Like I said in the reproduce steps, this isn't just a vanilla Magento 2.2.6 enviroment.

I edited "vendor/magento/module-catalog-search/etc/search_request.xml". If I reverse does changes then it works. But I want to keep those changes since I dont want my search query to work with OR but with AND.

And those changes aren't made in pr -> #20727.

So if I can I'm reopening this since it isn't fixed.

@Luuk-Meijer
Copy link
Author

@engcom-backlog-nazar can this issue be opened again?

@ghost
Copy link

ghost commented Feb 8, 2019

@DeLuuk i'm will recheck, this must be environmental issue

@ghost
Copy link

ghost commented Feb 8, 2019

@DeLuuk yes this is non-issue after i apply changes from pr and set -> #21059 (comment)
selection_321

@Luuk-Meijer
Copy link
Author

@engcom-backlog-nazar but now change:
"vendor/magento/module-catalog-search/etc/search_request.xml" change

<query xsi:type="boolQuery" name="quick_search_container" boost="1">
    <queryReference clause="should" ref="search" />
    <queryReference clause="must" ref="category"/>
    <queryReference clause="must" ref="price"/>
    <queryReference clause="must" ref="visibility"/>
</query>

to

<query xsi:type="boolQuery" name="quick_search_container" boost="1">
    <queryReference clause="must" ref="search" />
    <queryReference clause="must" ref="category"/>
    <queryReference clause="must" ref="price"/>
    <queryReference clause="must" ref="visibility"/>
</query>

And see what happens then

@ghost
Copy link

ghost commented Feb 8, 2019

@DeLuuk yes i'm set this :)
selection_322

@Luuk-Meijer
Copy link
Author

@engcom-backlog-nazar oke in that case Im gone try editing that option file.

Where can I find that option file? The url you linked is just for MySql specific, not Magento specific.

I mean I can't put that in a .htaccess or something?

@ghost
Copy link

ghost commented Feb 8, 2019

@DeLuuk you on ubuntu ? this is in mysqld sudo nano /etc/mysql/mysql.conf.d/mysqld.cnf
find the [mysqld] section add following

[mysqld]
innodb_ft_min_token_size=2
ft_min_word_len=2

then restart mysql server

@Luuk-Meijer
Copy link
Author

@engcom-backlog-nazar is that server wide? I have my test shop on the same server as the live shops. So I want to be sure that I dont break anything

@ghost
Copy link

ghost commented Feb 8, 2019

@DeLuuk this will affect for all websites if they use same server. try to test this locally.

@Luuk-Meijer
Copy link
Author

@engcom-backlog-nazar I have CentOS not Ubuntu.

Also I know Im asking a lot of questions and this isn't support but how can I test it locally.. 😅

@ghost
Copy link

ghost commented Feb 8, 2019

@DeLuuk in centOS this file in -> /etc/my.cnf add after [mysqld]

innodb_ft_min_token_size=2
ft_min_word_len=2

@Luuk-Meijer
Copy link
Author

Oke @engcom-backlog-nazar Im gone have to believe you on your word then since Im not adding this for the live just yet!!

Im gone push it live next tuesday morning so I'm hoping this is gone work!!

Thanks for answering all my questions!

@ghost
Copy link

ghost commented Feb 8, 2019

@DeLuuk your welcome, But also add changes from reference Pull Request.

@Luuk-Meijer
Copy link
Author

@engcom-backlog-nazar Yes I realise that thanks!! Will do 😄

@Luuk-Meijer
Copy link
Author

@engcom-backlog-nazar Oke I just changed the files to match this commit and added this to /etc/my.cnf:

innodb_ft_min_token_size=2
ft_min_word_len=2

But I still can't search for "A-327".
(And yes I restarted mysql, upgraded, compiled, redeployed, reindexed and flushed the cache)

@ghost
Copy link

ghost commented Feb 13, 2019

@DeLuuk wrong commit you simply need add "-" to this ->
const SPECIAL_CHARACTERS = '-+~/\\<>\'":*$#@()!,.?=%&^';`

https://github.com/Nazar65/magento2/blob/7539e8e6829197467b59e417e317d38ea39a005b/lib/internal/Magento/Framework/Search/Adapter/Mysql/Query/Builder/Match.php#L29

@Luuk-Meijer
Copy link
Author

Luuk-Meijer commented Feb 13, 2019

@engcom-backlog-nazar the reason I did the other commit is because that commit was already in my Magento 2.2.6 environment.
But I just removed the other commit just incase. But that also doesn't work.

@ghost
Copy link

ghost commented Feb 13, 2019

@DeLuuk ok thanks, give me 5 minutes i'm will recheck, because i'm migrated to archlinux :)

@ghost
Copy link

ghost commented Feb 13, 2019

@DeLuuk
deepin-screen-recorder_chromium_20190213112004

@Luuk-Meijer
Copy link
Author

@engcom-backlog-nazar I see. I noticed that thats a 2.3dev environment. Does this also work on a 2.2.6 environment?

@ghost
Copy link

ghost commented Feb 13, 2019

@DeLuuk hm.. try change to <queryReference clause="should" ref="search" />

@Luuk-Meijer
Copy link
Author

@engcom-backlog-nazar yeah but that's the whole point! That would indeed work.

But then if customers search for "Blue boots" they get all the products with "Blue" or "boots". My client wants to only show products that have "Blue" and "boots". That way the search results go from 300 to 20.

@ghost
Copy link

ghost commented Feb 13, 2019

@DeLuuk yeap, i'm found the problem this works for skus like this 41-315 but does not for sku like yours A-315

@Luuk-Meijer
Copy link
Author

Oke @engcom-backlog-nazar but now what?

Can this be fixed or is it already fixed somewhere? Or?

@ghost
Copy link

ghost commented Feb 13, 2019

@DeLuuk i will recheck it deeper this may be related to minimal search words, but anyway i'm will reopen this if have no solution and this caused by magento

@ghost
Copy link

ghost commented Feb 13, 2019

@DeLuuk The core problem in Mysql because they have not ability to set min_search_world to =1 , your select is AGAINST ('+a* +315*' IN BOOLEAN MODE)) where +a have 1 lenth word that mysql does not find product but if you have 2 words that it works.

@Luuk-Meijer
Copy link
Author

@engcom-backlog-nazar oke so you're saying that for it to work you need to be able to search for 1 character?
Damn... That works great for "A-327", but if 10 people search for just "A" that could be bad..

What do you suggest? Is there a fix for this?

@ghost ghost reopened this Feb 13, 2019
@ghost ghost added Issue: Clear Description Gate 2 Passed. Manual verification of the issue description passed Component: CatalogSearch Reproduced on 2.3.x The issue has been reproduced on latest 2.3 release labels Feb 13, 2019
@ghost
Copy link

ghost commented Feb 13, 2019

@DeLuuk https://lists.mysql.com/mysql/174354

@ghost
Copy link

ghost commented Feb 13, 2019

@DeLuuk this is Mysql bug https://bugs.mysql.com/bug.php?id=2095

@ghost ghost closed this as completed Feb 13, 2019
@ghost
Copy link

ghost commented Feb 13, 2019

@DeLuuk here is another workaround. It was recently added to the manual:
"
Modify a character set file: This requires no recompilation. The true_word_char() macro uses a “character type” table to distinguish letters and numbers from other characters. . You can edit the contents in one of the character set XML files to specify that '-' is a “letter.” Then use the given character set for your FULLTEXT indexes.
"

@Luuk-Meijer
Copy link
Author

@engcom-backlog-nazar Oke and I'm guessing you have to use the true_word_char() macro when you sent the string to mysql?
If so, do you know the file that that's located in? I had searched that file for a long time and couldn't find it before..

But again thanks for helping me so far!

@Puru2016
Copy link

Any solution in Magento 2.2.6 ? I am still facing this issue

@Luuk-Meijer
Copy link
Author

@Puru2016 in the end I didn't get it working with standard Magento 2 unfortunately.

I did however install this extension that made it work.

https://mirasvit.com/magento-2-extensions/sphinx-search-ultimate.html

@toan-tam
Copy link

@Puru2016 in the end I didn't get it working with standard Magento 2 unfortunately.

I did however install this extension that made it work.

https://mirasvit.com/magento-2-extensions/sphinx-search-ultimate.html

Thanks for pointing it out. Mirasvit extension works for me as well.

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: CatalogSearch Issue: Clear Description Gate 2 Passed. Manual verification of the issue description passed Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed Reproduced on 2.3.x The issue has been reproduced on latest 2.3 release
Projects
None yet
Development

No branches or pull requests

4 participants