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)

2
  • You mean when searching entries with ElementCriteriaModel? Would you mind adding an example code snippet for context?
    – Matt Stein
    Commented Jun 18, 2014 at 14:56
  • Does rebuilding the search indexes help? Commented Jul 3, 2014 at 6:40

1 Answer 1

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)
3
  • Looks like a bug with multibyte strings in the search query parser. Thanks for posting that – I’ll look into it. Commented Jul 3, 2014 at 21:52
  • 2
    Yep… fixed for the next release! Commented Jul 3, 2014 at 23:26
  • Nice answer Marion! Commented Jul 4, 2014 at 5:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.