A weird search problem
Permalink 1 user found helpful
Hi,
I have a problem with Concrete5's Search. I suspect it's somehow related to character encoding, but it's not the html entities confusion which seems to be common. Or a case of old index.
- TinyMCE is set NOT to convert characters to html entities. So for example characters like ä and ö are not converted. I've checked this from the database. Also the PageSearchIndex table has the characters as they should be.
- Everything is in utf-8.
The search works when I for example search for a single character like 'ä', several pages are found.
But when I search for 'Kaurismäki', there is no search results. Searching with 'Kaurism' or 'äki' finds the correct pages, so I guess it has something to do with special characters. But I don't have any clue as to what could be the problem.
Based on the previous, it seems to be a problem when a character like 'ä' is in the middle of a search string. If it's in the beginning or the end (searching for 'Kaurismä' works!), everything works.
I have a problem with Concrete5's Search. I suspect it's somehow related to character encoding, but it's not the html entities confusion which seems to be common. Or a case of old index.
- TinyMCE is set NOT to convert characters to html entities. So for example characters like ä and ö are not converted. I've checked this from the database. Also the PageSearchIndex table has the characters as they should be.
- Everything is in utf-8.
The search works when I for example search for a single character like 'ä', several pages are found.
But when I search for 'Kaurismäki', there is no search results. Searching with 'Kaurism' or 'äki' finds the correct pages, so I guess it has something to do with special characters. But I don't have any clue as to what could be the problem.
Based on the previous, it seems to be a problem when a character like 'ä' is in the middle of a search string. If it's in the beginning or the end (searching for 'Kaurismä' works!), everything works.
Anyone? I still haven't found any logic in this, so it feels like a bug.
I have the same problem. Don't know solution
I think this is a problem with the search controller being somewhat stupid in 5.4.1.1. This has been fixed in development. If you download concrete/blocks/search/controller.php from here:
https://github.com/concrete5/concrete5/tree/master/web/concrete/bloc...
And try replacing concrete/blocks/search/controller.php with that file, let me know if that helps.
https://github.com/concrete5/concrete5/tree/master/web/concrete/bloc...
And try replacing concrete/blocks/search/controller.php with that file, let me know if that helps.
That works, Thanks ;)
Hi Andrew,
I used the current version of controller.php on Github to fix the problem of only single words being found by the search function.
However, a new problem appeared for me:
I have set up the search block so that the results appear in the Main area under another page which still has a search field at the top of the page.
This resulted in the results being listed twice, once in the main area and again under the original search field.
I noticed that this line (150 on Github) was changed from:
To:
I changed it back and it works as before but was wondering what the reason for the change was and whether it will impact anything else?
Cheers
I used the current version of controller.php on Github to fix the problem of only single words being found by the search function.
However, a new problem appeared for me:
I have set up the search block so that the results appear in the Main area under another page which still has a search field at the top of the page.
This resulted in the results being listed twice, once in the main area and again under the original search field.
I noticed that this line (150 on Github) was changed from:
if((empty($_REQUEST['query']) && $aksearch == false) || $this->resultsURL != '') { return false; }
To:
if((empty($_REQUEST['query']) && $aksearch == false)') { return false; }
I changed it back and it works as before but was wondering what the reason for the change was and whether it will impact anything else?
Cheers
Incidentally, I also changed this line:
To:
This now allows for the search term highlight color to be defined in the style sheet.
Thought someone might find this useful.
$this->hText = @preg_replace( "#$this->hHighlight#i", '<span style="background-color:'. $this->hColor .';">$0</span>', $this->hText );
To:
$this->hText = @preg_replace( "#$this->hHighlight#i", '<span style="background-color:'. $this->hColor .';"><span class="searchHighlight">$0</span></span>', $this->hText );
This now allows for the search term highlight color to be defined in the style sheet.
Thought someone might find this useful.