craftcms / cms

Build bespoke content experiences with Craft.
https://craftcms.com
Other
3.2k stars 617 forks source link

[4.x]: Search index algorithm not functioning as expected #15250

Closed trevor-cuffe closed 6 days ago

trevor-cuffe commented 1 week ago

What happened?

Description

When searching for a query containing multiple words (ex. S80 pvc pipe), the search index query returns all result rows from that table that contain each of those terms. However, if I have a product entry with multiple searchable fields, I would like to return a product which has each term spread out between those fields (for example, it may have the words "pvc" and "pipe" in the title, and "s80" in the description field)

Steps to reproduce

  1. Set up and populate an entry section with multiple searchable fields
  2. Run a search query for entries matching that section, with a search query containing multiple words, which appear in different searchable fields

Expected behavior

An element which has each searched term in ONE of its searchable fields, regardless of whether these terms appear in the same field or different ones, would return in the search results.

Actual behavior

Only products which have all terms in the SAME searchable field return. For example, a product titled "10 foot S80 PVC pipe" returns, but a product titled "10 foot PVC pipe" with a searchable description field containing the word "S80" does not return.

Craft CMS version

4.9.2

PHP version

8.1

Operating system and version

No response

Database type and version

No response

Image driver and version

No response

Installed plugins and versions

No response

brandonkelly commented 6 days ago

This is behaving as expected (documented here).

The Scout plugin might be worth looking at – which connects Craft to Algolia and offers much more flexibility in terms of how keywords are indexed, etc.