Substring productsearch (PostgreSQL)

Help for integrating the Laravel package
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!
columbo
Advanced
Posts: 125
Joined: 09 Oct 2019, 09:42

Substring productsearch (PostgreSQL)

Post by columbo » 22 Jan 2024, 12:16

Hi,

given a searchterm like: "bar"
-> product with names like "foo bar baz" are found

But products with seachterm as part of a word (substring) are not found:
  • "barfoobaz"
  • "foobarbaz"

How / where can we customize the search / SQL behaviour especially for PostgreSQL?
I know that this will degrade the performance; we only have a few articles (< 5.000) but with complex names

thank you

User avatar
aimeos
Administrator
Posts: 7894
Joined: 01 Jan 1970, 00:00

Re: Substring productsearch (PostgreSQL)

Post by aimeos » 23 Jan 2024, 11:35

columbo wrote: 22 Jan 2024, 12:16 given a searchterm like: "bar"
-> product with names like "foo bar baz" are found

But products with seachterm as part of a word (substring) are not found:
"barfoobaz"
This should be found too because PostgreSQL and all other RDBMs use prefix search.
columbo wrote: 22 Jan 2024, 12:16 "foobarbaz"
This can't be found because "bar" is not at the beginning of a word.
columbo wrote: 22 Jan 2024, 12:16 How / where can we customize the search / SQL behaviour especially for PostgreSQL?
I know that this will degrade the performance; we only have a few articles (< 5.000) but with complex names
You can use the "Standard" index manager implementation, which uses a LIKE search (very slow for 10k+ products but finds strings anywhere):
https://github.com/aimeos/aimeos-larave ... #L287-L306
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

columbo
Advanced
Posts: 125
Joined: 09 Oct 2019, 09:42

Re: Substring productsearch (PostgreSQL)

Post by columbo » 29 Jan 2024, 13:01

Thank you, but still one question.

given following available products name:
  • "foobarbaz abc 2kg"
  • "foobarbaz abc 5kg"
  • "foobarbaz abc 9kg"
when using "Standard index manager" and searching for "bar", result:
  • "foobarbaz 2kg"
  • "foobarbaz 5kg"
  • "foobarbaz 9kg"
-> ok, all porducts are found:


seachring for "foobarbaz abc 5kg"
  • "foobarbaz abc 5kg"
-> ok, only one product is found:


but searching for "bar 5kg"
expected: "foobarbaz abc 5kg"
-> in fact no articles are found

So "Standard index manager" seaches for the exact, entire term ("bar 5kg") and not the individual terms ("bar" and "5kg").
Are there any possibilities to extend the search manager as described?

User avatar
aimeos
Administrator
Posts: 7894
Joined: 01 Jan 1970, 00:00

Re: Substring productsearch (PostgreSQL)

Post by aimeos » 30 Jan 2024, 08:44

No, this requires the full text index which splits up the text into words and creates an index for these words. The SQL LIKE based search can't do that.
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

Post Reply