Closed ahoek closed 4 years ago
Hey, first of all - thanks a lot for the contribution! Could you give some examples how you use wildcard and fuzzy keywords?
This part of the bundle is actually implemented very similar to the original Sulu search controller: https://github.com/sulu/sulu/blob/4d5543623b2c45adb2dbc3a9b95809aac651344f/src/Sulu/Bundle/SearchBundle/Controller/WebsiteSearchController.php#L79-L87
I am not sure if we should diverge from the default Sulu behaviour in the bundle. But maybe we should change this in the default Sulu search controller too?
I haven't used the original Sulu search controller, but the issue I encountered was as follows:
If I search on the term keywor
, the prepareQuery function creates the following query for the Massive search bundle (I use the Elastic adapter):
+("keywor" OR "keywor*" OR "keywor~")
Because the terms "keywor*"
and "keywor~"
are enclosed in "
, Elastic will search on the literal terms instead of using the wildcard (*
) or fuzzy (~
) modifiers.
When I remove the double quotes, documents which contain keyword
or keywords
for example will be found.
+("keywor" OR keywor* OR keywor~)
Thanks for the explanation! I just tested the behaviour with the original Sulu search controller and can verify the behaviour there. I think this is not intended and created a PR for the original search controller: https://github.com/sulu/sulu/pull/5407
I would like to wait and see if the Sulu PR is accepted before merging this to keep things consistent, I hope that is okay for you. You should be able to overwrite the controller inside of your project via decoration in the meantime: https://symfony.com/doc/current/bundles/override.html#controllers
Thanks again for your effort!
Ok, that seems ok that first the functionality in Sulu itself is reviewed.
While working on this system, I noticed an additional bug. When the search query begins or ends in a space, the generated query is invalid and gives a 500 error when executed.
For example:
search query: "keywor "
(with a space at the end)
generated query string: +("keywor" OR keywor* OR keywor~) +()
This would be solved if empty values from the explode
d string would be filtered out.
@ahoek Thank you for report and fixing this!
This is a fix for issue #36