5

There seems to be a bug when I combine non-ascii characters, quotes and the OR operator when searching.

All of these queries work ok:

  • "pølser"
  • "pålegg"
  • pølser OR pålegg
  • "egg" OR "spekemat"

but

  • "pølser" OR "pålegg"

always returns no result.

The search form uses roughly this code:

{% set searchTerm = craft.request.getParam('search') %}

{% set entries = craft.entries %}

... entries is optionally limited to a single section here, but it makes no difference here ... 

{% set entries = entries.search(searchTerm) %}

Any ideas?

Cheers!

(cross-posted from google+ group as I only just found out about the stack-exchange)

(edit to add code sample)

gromgull
  • 631
  • 4
  • 12

1 Answers1

6

This looks like a bug to me too. Here are the search terms and generated queries:

'pølser OR pålegg' -
   SELECT * FROM `craft_searchindex` WHERE (MATCH(`keywords`) AGAINST('pølser palegg' IN BOOLEAN MODE)) AND `elementId` IN (3,18,21,22,23,24)

'"pølser" OR "pålegg"' -
   SELECT * FROM `craft_searchindex` WHERE (`keywords` LIKE '% pølser or %') AND MATCH(`keywords`) AGAINST('+palegg' IN BOOLEAN MODE) AND `elementId` IN (3,18,21,22,23,24)

'"egg" OR "spekemat"' -
   SELECT * FROM `craft_searchindex` WHERE ((`keywords` LIKE '% egg %') OR MATCH(`keywords`) AGAINST('spekemat' IN BOOLEAN MODE)) AND `elementId` IN (3,18,21,22,23,24)
Marion Newlevant
  • 12,047
  • 22
  • 55