Search

Well, I did take time to take a quick look and found that I probably can’t help you. It’s working well on my live site which is running 2.0.6, but I get the same error as you on my test site which is running 2.0.8RC1.

I limit my search to a section called blogposts and get an error on its authors field. The authors field is the first field with no value field in the DB.

So, it seems likely that you’re running a version later than 2.0.6. But let me know if that’s not the case.

I replaced this in event.searchresults.php:

foreach($fieldsResult as $field) {
    $sql = 'SELECT `entry_id` FROM `sym_entries_data_'.$field['id'].'` WHERE `value` LIKE '%'.implode('%' OR `value` LIKE '%', $keywords).'%';';
    $entriesResult = $this->_Parent->Database->fetch($sql);
    if(!empty($entriesResult)) {
        foreach($entriesResult as $a) {
            if(!in_array($a['entry_id'], $matches)) {
                // We have a match!
                array_push($matches, $a['entry_id']);
            }
        }
    }
}

with this:

foreach($fieldsResult as $field) {
    $query = "SHOW COLUMNS FROM sym_entries_data_".$field['id']." LIKE 'value'";
    $columns = $this->_Parent->Database->fetch($query);
    if ($columns) {
        $sql = 'SELECT `entry_id` FROM `sym_entries_data_'.$field['id'].'` WHERE `value` LIKE '%'.implode('%' OR `value` LIKE '%', $keywords).'%';';
        $entriesResult = $this->_Parent->Database->fetch($sql);
        if(!empty($entriesResult)) {
            foreach($entriesResult as $a) {
                if(!in_array($a['entry_id'], $matches)) {
                    // We have a match!
                    array_push($matches, $a['entry_id']);
                }
            }
        }
    }
}

and now it works in 2.0.8RC1. These changes were only made to my local test site.

cool. i’ll try that out and report back.

The remaining question is, why did this work on 2.0.6? I’m using the same database with both the 2.0.6 site and the 2.0.8RC1 site.

@kanduvisla: An alternative to using my fix is to expand your config.searchresults.regular.php file to include the fields to be searched in each section. This would reduce the number of db queries needed — both from my fix and potentially from fields that have a ‘value’ db column but that you don’t really need to search. One downside, though, is the need to remember to edit the config file when a section is changed.

The remaining question is, why did this work on 2.0.6? I’m using the same database with both the 2.0.6 site and the 2.0.8RC1 site.

Most likely because 2.0.6 treated SQL errors more forgivingly. Maybe with 2.0.6 the errors are suppressed and logged only to the manifest/log file, whereas 2.0.8 may fail fatally, perhaps?

An alternative to using my fix is to expand your config.searchresults.regular.php file to include the fields to be searched in each section

This would be preferable particularly from a security perspective (what if you had a text field in your section that you didn’t want searchable?)

I got another error with this extension:

Fatal error: Allowed memory size of 16777216 bytes exhausted (tried to allocate 525680 bytes) in /var/www/symphony-2/symphony/lib/toolkit/class.xmlelement.php on line 177

I got it when I tried to search for George Will. It performs an or search on each of the words and since Will is a common word it was found in enough posts to exceed the memory limit. I can live with this limitation. In this case I searched on George only and got what I was looking for.

For me problems is’t solved. “Division by zero” error apeare. To my mind some problems with SQL syntax. After this rev search work correctly

$sql = 'SELECT `entry_id` FROM `sym_entries_data_'.$field['id'].'` WHERE `value` LIKE '%'.implode('%' OR `value` LIKE '%', $keywords).'%';';

to

$sql = 'SELECT `entry_id` FROM `sym_entries_data_'.$field['id'].'` WHERE `value` LIKE \'%'.implode('%\' OR `value` LIKE \'%', $keywords).'%\';';

Be careful, this Symphony Forum Engine automatically drop all escaped slashes. So we should use double slashes for right syntax. (e.g. \n -> \\n)

My copy of event.searchresults.php already contains the correct form of the line you changed. Apparently you copied my fix from above, from which the backslashes had been dropped by this forum engine.

This is a bit of a nuisance. Every time that we copy and paste a code block we have to go through it and double all the backslashes?

@wisolman, yes I do it evry time when add code to forum.


IMHO this extension need data filtering, such us

Add this code (backslashes is added, code copypastable)

    $query = substr($query, 0, 200); 
    $query = preg_replace("/[^\w\x7F-\xFF\s*.]/", " ", $query); 
    $query = trim(preg_replace("/\s(\S{1,2})\s/", " ", ereg_replace(" +", "  "," $query "))); 
    $query = ereg_replace(" +", " ", $query);

befor

    $keywords   = explode(' ', $query );        // An array with keywords

for filtering incoming data

or download rev file searchresults 0.2.zip

Attachments:
searchresults 0.2.zip

Thanks wisolman + Alixon!

I had a file input field that this extension was failing with… it’s all working nicely now.

A quick question - am I doing something wrong?

If there are characters like & (ampersand) in the search results I think it’s producing bad XML.

See this discussion of a problem with ampersand’s in the title. It might provide some insight into your problem.

Thanx wisolman and Alixon for improving the search results extension. Have been rather busy at work lately, so I wasn’t able to reply very much, but I’ll take your improvements/bugfixes in version 0.3 and post them on github asap.

However, my gitHub account is currently blocked for some reason, so I have to figure out why that is. I already contacted them.

Search Results updated to version 0.3 on 28th of July 2010

Search Results updated to version 0.4 on 2nd of September 2010

  • Fixed bug with sym_-prefix
  • Added value_formatted functionality
  • Added total-results parameter

Great! thanks

i have followed the “Search Results” Description procedure to create multiple select words, but it is not working for my project..I am not getting the output for Search results.. Please give more description about search results extension like sample xslt code…

this extension works well for one particular field…how to create links for all fields for a section not to particular field like ‘title’ in a given example xslt code..

Hi kanduvisla, I worked on this module, Thanks for presenting this. and is there any possibility to highlight the keyword in the search result. and fetch and show the substring of that particular portion alone

Create an account or sign in to comment.

Symphony • Open Source XSLT CMS

Server Requirements

  • PHP 5.3-5.6 or 7.0-7.3
  • PHP's LibXML module, with the XSLT extension enabled (--with-xsl)
  • MySQL 5.5 or above
  • An Apache or Litespeed webserver
  • Apache's mod_rewrite module or equivalent

Compatible Hosts

Sign in

Login details