Full text search by supplier name and product name

How to configure and adapt Aimeos based shops as developer
Forum rules
Always add your Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
User avatar
VadimSaratov
Posts: 8
Joined: 09 May 2022, 15:27

Full text search by supplier name and product name

Post by VadimSaratov » 08 May 2023, 09:49

I have a question about full text search. I have a requirement to fetch search results by supplier name and product name in one query. I found a way to get this by generating different texts for each product but maybe there is a better solution?

For example, I have a supplier name "Dixie Home" and a product name
"Mystic Rain Master"

I would like this product to appear in search results if I use one of the following search texts:
"Dixie Home"
Mystic Rain,
"Dixie Mystic"
"Dixie Home"
Mystic", etc.

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

Re: Full text search by supplier name and product name

Post by aimeos » 10 May 2023, 06:31

If you add a supplier to a product, the supplier name will be stored together with the other product texts, so this should work out of the box then: https://github.com/aimeos/aimeos-core/b ... #L739-L741
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

User avatar
VadimSaratov
Posts: 8
Joined: 09 May 2022, 15:27

Re: Full text search by supplier name and product name

Post by VadimSaratov » 10 May 2023, 09:21

Thx for your answer.

It works if I use only the supplier name or only the product name, but not some words from the supplier name and some words from the product name in the same request

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

Re: Full text search by supplier name and product name

Post by aimeos » 11 May 2023, 06:50

Which Aimeos version do you use?
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

User avatar
VadimSaratov
Posts: 8
Joined: 09 May 2022, 15:27

Re: Full text search by supplier name and product name

Post by VadimSaratov » 11 May 2023, 15:14

I use aimeos-laravel 2022.10

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

Re: Full text search by supplier name and product name

Post by aimeos » 12 May 2023, 07:36

That's strange. Can you please have a look into the mshop_index_text table if there's a record that contains both strings? By default, the product texts and the supplier names are concatenated into one string and stored as one record. Querying the MySQL full text index should then find the words from both, product and supplier name.
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

User avatar
VadimSaratov
Posts: 8
Joined: 09 May 2022, 15:27

Re: Full text search by supplier name and product name

Post by VadimSaratov » 23 May 2023, 16:50

Hi Aimeos, sorry for such a late reply, yes mshop_index_text contains an entry with the supplier name and the product name

I also debugged the index manager and found this SQL query

Code: Select all

SELECT mpro."id"
FROM "mshop_product" mpro
         LEFT JOIN "mshop_index_catalog" AS mindca ON mindca."prodid" = mpro."id"
         LEFT JOIN "mshop_index_text" AS mindte ON mindte."prodid" = mpro."id"
WHERE ((mpro."siteid" IN ('', '1.'))
    AND (mindca."catid" IS NOT NULL AND
         ((mindte."siteid" IN ('', '1.')) AND mindte."langid" = 'en' AND POSITION('engineered' IN mindte."content") > 0 OR
          mpro."code" LIKE 'Engineered%' ESCAPE '#')
        AND ((mpro."status" = 1)
            AND (mpro."type" = 'event' OR mpro."start" IS NULL OR mpro."start" <= '2023-05-23 14:49:00')
            AND (mpro."end" IS NULL OR mpro."end" >= '2023-05-23 14:49:00'))))
GROUP BY mpro."id"
ORDER BY mpro."id"
LIMIT 10000 OFFSET 0
for example I have supplier name "Engineered Floors" and product name "Authentic Living"
and I can get search results if I use any of the word sets that match the order in "Engineered Floors Authentic Floors"

so the search for such strings will work: "Engineered", "Engineered Floors", "Authentic Living", "Floors Authentic", etc.

If I want to mix word order like: "Engineered Authentic", "Engineered Living", "Floors Floors"
then I need to create an extra entry in mshop_index_text with strings that will match that right?

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

Re: Full text search by supplier name and product name

Post by aimeos » 24 May 2023, 10:37

You are using the Standard index/text manager instead of the Mysql or Pgsql one. Thus, you get the behavior your are describing because the POSITION/LIKE search is very limited in what it can find.
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

User avatar
VadimSaratov
Posts: 8
Joined: 09 May 2022, 15:27

Re: Full text search by supplier name and product name

Post by VadimSaratov » 24 May 2023, 12:04

Ohhh, thanks a lot, it works now

Post Reply