Change filtering query
Forum rules
Always add your Laravel, Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
Always add your Laravel, Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
Change filtering query
Hello!
We are trying to find a way to change how filtering for our shop work. As much as I can guess, by default it splits the typed string to all words, ignores all that are 2 characters or less, and searches with "%word-one% OR %word-two% OR ... ". This logic doesn't work well when, for example, we type something like "Apple iPhone 7" or "Samsung Galaxy S9" because we get results for other products that contain at least one of the words in the searched string.
Could you please help with ideas or ways to change how the filtering works?
Thank you in advance!
We are trying to find a way to change how filtering for our shop work. As much as I can guess, by default it splits the typed string to all words, ignores all that are 2 characters or less, and searches with "%word-one% OR %word-two% OR ... ". This logic doesn't work well when, for example, we type something like "Apple iPhone 7" or "Samsung Galaxy S9" because we get results for other products that contain at least one of the words in the searched string.
Could you please help with ideas or ways to change how the filtering works?
Thank you in advance!
Re: Change filtering query
Aimeos uses standard MySQL full text search by default (or the one offered by PosgreSQL) which is similar to:
Product texts matching all or more than one word are ranked higher but MySQL skips word with 3 chars or less, so "S9" won't be used at all (depends on the MySQL server config).
If you need exact matchs, you can use the "Standard" text index manager:
https://github.com/aimeos/aimeos-core/b ... andard.php
Configuration:
Be aware that MySQL is unable to use indexes then and your search will be painfully slow if you have a lot of products!
If you need a better full text search which is fast too, then have a look at Solr and the Solr extension from the Aimeos company:
https://aimeos.com/extensions#c606
Code: Select all
"Samsung%" OR "Galaxy%" OR "S9%"
If you need exact matchs, you can use the "Standard" text index manager:
https://github.com/aimeos/aimeos-core/b ... andard.php
Configuration:
Code: Select all
'mshop' => array(
'index' => array(
'manager' => array(
'text' => array(
'name' => 'Standard',
),
),
),
),
If you need a better full text search which is fast too, then have a look at Solr and the Solr extension from the Aimeos company:
https://aimeos.com/extensions#c606
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos,
give us a star
If you like Aimeos,
![Image](https://aimeos.org/fileadmin/aimeos.org/icons/star.png)
Re: Change filtering query
Thank you for the answer!
That throws some light on how things work exactly.
If these are the only options, the default will have to do, as the "Standard" configuration actually didn't return any products even when trying with copying the exact name of a product and searching with it.
Do you think an extension to the Index/Manage/Text/Standard class could be made that is configured to search by "mindte.value LIKE '%Some phrase or something%' "? I think this will be the ideal way for our case - at least for what our client wants.
Thank you very much again!
That throws some light on how things work exactly.
If these are the only options, the default will have to do, as the "Standard" configuration actually didn't return any products even when trying with copying the exact name of a product and searching with it.
Do you think an extension to the Index/Manage/Text/Standard class could be made that is configured to search by "mindte.value LIKE '%Some phrase or something%' "? I think this will be the ideal way for our case - at least for what our client wants.
Thank you very much again!
Re: Change filtering query
You can create your own full text search creating a new text index manager, inheriting from the standard class and overwrite these lines: https://github.com/aimeos/aimeos-core/b ... p#L59-L108
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos,
give us a star
If you like Aimeos,
![Image](https://aimeos.org/fileadmin/aimeos.org/icons/star.png)
Re: Change filtering query
Hello again and sorry for asking stupid questions once more.
When inspecting the query that is generated in the end by looking at the mysql general log, for the part where the exact search term is replaced, it goes in like
We are currently using 2018.04 version of Aimeos, and as far as I can see, in newer versions this file class doesn't even exist there since 2018.10 version. (https://github.com/aimeos/aimeos-core/b ... /MySQL.php)
So, without updating to newer version, my only option is to extend the Standard Text Manager class and modify the query. Does it matter where exactly the extending class is placed within the project? And is this the way that the config should look like?
When inspecting the query that is generated in the end by looking at the mysql general log, for the part where the exact search term is replaced
Code: Select all
POSITION( $3 IN mindte2."value" ) > 0
Code: Select all
POSITION( ' +Apple* +iPhone* 7*' IN mindte2.`value` ) > 0
So, without updating to newer version, my only option is to extend the Standard Text Manager class and modify the query. Does it matter where exactly the extending class is placed within the project? And is this the way that the config should look like?
Code: Select all
'mshop' => [
'index' => array(
'manager' => array(
'text' => array(
'name' => 'Path\To\CustomStandard',
),
),
),
],
Re: Change filtering query
In 2018.10, the code has been moved to the text index manager:
https://github.com/aimeos/aimeos-core/b ... p#L80-L101
If you need to create your own custom index manager, file location matters. If you configure this:
Then, your custom manager must be in
Please note that 2018.04 isn't supported any more at all and 2018.10 only by the extended LTS program of the Aimeos company:
https://aimeos.com/support#c428
https://github.com/aimeos/aimeos-core/b ... p#L80-L101
If you need to create your own custom index manager, file location matters. If you configure this:
Code: Select all
'mshop' => [
'index' => array(
'manager' => array(
'text' => array(
'name' => 'MyProject',
),
),
),
],
Code: Select all
./ext/<yourext>/lib/custom/src/MShop/Index/Manager/Text/MyProject.php
https://aimeos.com/support#c428
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos,
give us a star
If you like Aimeos,
![Image](https://aimeos.org/fileadmin/aimeos.org/icons/star.png)