Search

Exactly :-)

Imagine you had a site with Users, Articles and Videos. The search could display a User profile image, their profile and a link to their profile page. An Article could show the title, summary and link to an article page. A Video could be represented by a thumbnail and caption, or the video embedded itself.

My very basic XSL above alluded to this — a separate template for each content type in the search results, allowing the developer to choose which content to display and how.

To clear up any confusion, it’s probably easiest to think of these search ideas in terms of horizontal and vertical search.

Using the Google CSE or Yahoo! BOSS extensions provide a true horizontal search of your site. They will index page contents across your entire site, regardless of site section (about, products, corporate, etc).

A Symphony Data Source provides a very narrow vertical search — you filter a particular Symphony section, which provides results from that vertical niche only. Creating a native Symphony search extension would widen this vertical scope, but remains vertical nonetheless.

Suggest develop different search options GSCE, YBOSS, native Symphony search, or other implementations. Use specific based on site specifics.

As much as it irks me to say this, I don’t know that searching should ever be a built-in part of a WCMS like Symphony for exactly the reasons Nick and Rowan outlined earlier in the thread (pre-rendered text, database performance implications).

You’re almost always better off integrating with an external service - at my current workplace, we have two Google Mini servers that are pretty much perfect for what you’d look to do with searching and returning results from a standard Symphony install. It doesn’t help hobbyists due to the (actually very cheap!) price tag of these boxes - I realise most users want a free solution to the problem.

Does anything exist like Solr (http://lucene.apache.org/solr/features.html) for PHP/Python/Ruby? Most of the shared hosts don’t support Java, and would definitely not support a memory intensive J2EE application like a search indexer.

I don’t know much about it but how hard would it be to integrate something like Sphinx into a Symphony installation? It’s supposed to be able to handle XML content.

After getting bad results with Yahoo search a client asked me to go the native Symphony route. I was wondering why Google is so much more popular then Google, but perhaps Yahoo should try and count the occurrences of a search word and display the pages with most occurrences first.

I used the Reflection Field extension to group several section fields in one. The latest version of this extension also allows for searching and using regular expressions. Unfortunately, results are mixed.

Last year, Lewis wrote the following

Right now I’m just trying to match a text input. I would like: adult sail To match: Adult Beginner Sailing The REGEX solution would be adult|sail but there’s no way to alter the search (without utilizing an event).

With the Reflection Field, this is easily done. I just added $pattern = '(' . str_replace(' ', '|', $pattern) . ')'; on line 320 of field.reflection.php, but I can imagine that someone wants a more solid solution. It would be great to get some sort of ranking based on the amount of matches, e.g. get an entry which matches more terms in a higher rank, but at least this is some progress…

Regarding comments 10 and 11

Are you trying to match data in a textarea or something else? Right now I’m just trying to match a text input. I would like:

adult sail

To match:

Adult Beginner Sailing

The REGEX solution would be adult|sail but there’s no way to alter the search (without utilizing an event).

Rather than hacking the field class, you can hack the datasource.

I have a datasource called “Product Search” and added this as first line in the grab function:

$this->dsParamFILTERS['33'] = str_replace(' ', '|', $this->dsParamFILTERS['33']);

The term “adult sail” matches “Adult Beginner Sailing”.

My last entry was slightly wrong - using regexp:[[:<:]]{$url-search}[[:>:]] matches whole words only, so searching for “sail” would not return “Adult Beginner Sailing”.

To fix this, I changed the datasource to filter by $url-search, then added the following two lines to the Grab function in the datasource.

if ($this->dsParamFILTERS['33'] == '') return $this->emptyXMLSet();
$this->dsParamFILTERS['33'] = "regexp:" . str_replace(' ', '|', $this->dsParamFILTERS['33']);

James, this works beautifully (thanks!), but when I change some settings of this data source in the Symphony administration, it overwrites my Grab function to the default and I have to change it again. Do you know of a way to force it to stay there?

Remove, or set the allowEditorToParse function in that datasource file to be false.

That will of course stop you from editing it in the admin interface.

Hi! I apologize for bringing up an old thread but I find this type of filtering really useful.

For a basic search I have implemented it on a text input field (regexp:{$url-keywords}), but I am confused about the following:

In the front-end form, if the keywords are separated by |, the filter considers it OR, filtering entries correctly, only if they are arranged in the order the entries were created.

For example:

There are three entries - 1, 2 and 3, with 1 being the first created. Each entry contains a keyword - keyword1, keyword2 and keyword3 respectively. There is also a keyword1b in entry 1.

  • keyword1 | keyword2 | keyword3 returns all three entries (as expected);
  • keyword3 | keyword1 | keyword2 returns only entries 1 and 2;
  • keyword3 | keyword2 | keyword1 (or keyword2 | keyword3 | keyword1) returns only entry 1;
  • keyword1 | keyword1b returns (correctly) only entry 1, regardless of the order.

I wonder if anyone else has encountered this. Was it too unrealistic to presume that the | would work on the front-end?

Thanks and I appreciate your help!

I don't got the answer for this, but i suggest using the search index extension...
works perfect for this use case, not sure if it's updated for 2.4 though...

Edit: Tested it, but does not seem to find a match when multiple search words are entered...
So i'm not sure this is helpful... At least i tried ;-)

Maybe ElasticSearch?

Thanks, Cremol. I'll go with ElasticSearch as soon as I set up the server.

I think multiple entries are returned only if the keywords are separated with |, otherwise it's considered a phrase.

I am quite sure I found out what the problem was - the space. When keywords are entered like this: keyword3|keyword1|keyword2 (without any space around the |), then entries seem to be returned correctly.

Edit (01.07.2014):

For anyone interested, after some more testing, everything seems to work as expected, so I implemented the above with a custom event that replaces spaces with a |:

public $elementName = 'keywords';

public function load(){
    if (isset($_GET[$this->elementName])) {
        $page = Frontend::instance()->Page();
        $page->_param['url-'. $this->elementName] = str_replace(' ', '|', $_GET[$this->elementName]);
    };
}

(To avoid confusing the user I use translate($url-keywords, '|', ' ') in the xslt to display the keywords as entered.)

I think that for searching a single field a similar setup works nice and love that I can do that without extensions.

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