PostgreSQL: product search with multiple terms

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

Re: PostgreSQL: product search with multiple terms

Post by columbo » 09 Jan 2021, 09:17

tried it once again; results are not ranked by phrase queries
A product that exactly matches the search term is listed somewhere in between of the result product list

How can I retrieve the search query? Set log/manager/standard/loglevel to 7, but could not find the query .

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

Re: PostgreSQL: product search with multiple terms

Post by aimeos » 09 Jan 2021, 09:51

Did you set your configuration correctly in your ./config/shop.php?

Code: Select all

'madmin' => [
	'log' => [
		'manager' => [
			'standard' => [
				'loglevel' => 7
			]
		]
	]
],
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: PostgreSQL: product search with multiple terms

Post by columbo » 09 Jan 2021, 11:50

The config.php setting was correct, but could not finde a PgSQL protocol entry before, saved config.php file again and now its listed - anyway, here the logged PgSQL query: (term1 = "paprika"; term2 = "rot")

Code: Select all

Class: Aimeos\MShop\Index\Manager\PgSQL
SELECT mpro."id" , MIN(mpro."code") AS "s0", MIN(ts_rank(to_tsvector(mindte."content"), to_tsquery( 'paprika:* | rot:* | "paprika <-> rot"' ))) AS "s1"
    FROM "mshop_product" AS 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" = '1.' OR mpro."siteid" = '' ) AND ( mindca."catid" IS NOT NULL AND ( mpro."status" = 1 AND ( mpro."type" = 'event' OR mpro."start" IS NULL OR mpro."start" <= '2021-01-09 12:42:00' ) AND ( mpro."end" IS NULL OR mpro."end" >= '2021-01-09 12:42:00' ) ) AND ( mindte."siteid" = '1.' OR mindte."siteid" = '' ) AND mindte."langid" = 'de' AND CAST( to_tsvector(mindte."content") @@ to_tsquery( 'paprika:* | rot:* | "paprika <-> rot"' ) AS integer ) > 0 ) )
    GROUP BY mpro."id"
    ORDER BY "s0" ASC, "s1" DESC
    OFFSET 0 ROWS FETCH NEXT 48 ROWS ONLY

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

Re: PostgreSQL: product search with multiple terms

Post by aimeos » 09 Jan 2021, 12:31

You sort by product code first, so the ranking doesn't have any effect:

Code: Select all

MIN(mpro."code") AS "s0"
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: PostgreSQL: product search with multiple terms

Post by columbo » 09 Jan 2021, 13:38

ohh, yes indeed :oops:
we are using client/html/catalog/lists/sort => 'code'

is it possible to list products by code in category lists (without any search terms)
but to list by relevance (and not by product code) when search term(s) is/are used?

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

Re: PostgreSQL: product search with multiple terms

Post by aimeos » 11 Jan 2021, 08:48

If you create you own controller/action with the catalog/tree and add the setting in that method to the configuration, then it will be only used by that page.
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

Post Reply