Search

I’d like to implement a simple search for an internal site that I’ve created. Unfortunately since it is internal, the google and yahoo solutions aren’t in the playing cards.

I’ve found the following thread http://getsymphony.com/discuss/thread/40/ which I noticed Alistair mentioning you can filter a DS using REGEXP and Nick also showed an example concept of implementing one. But, I was wondering if there is an actual “How to”, since what they both mentioned didn’t click in my mind.

Really appreciate the help.

I’d second a walk through or rough giude.. couldn’t find anything in the tutorials about this kind of thing.

There is also a Google search extension.

Thanks, @phoque. I saw that, but unfortunately it’s an internal site so it won’t be index-able by google. Hence why I was asking for a walk-through on how to do this.

The problem with using a data source in combination with a regular expression is that the search results are not ranked by relevance. I use this solution for a project.

However, a better solution is to create a custom data source where you put in a custom SQL query ordering by relevance such as done for this forum. You can see an example in the Forum ensemble by Bauhause here. Be sure to install the Advanced Symphony Database Connector extension.

The query (line 82 to 100) is fairly complicated and I must admit that I also could use some explanations about how to apply it to different sections, especially when searching on the content of multiple entries across different sections.

Thanks Carsten, I’ll take a look at Bauhause’s ensemble. I’m still trying to figure out how that man sleeps.

I’d like to implement a simple search

It would be nice to do this natively with Symphony, so we don’t need to get into writing custom data sources. You’re wanting something simple, after all.

Could you be a bit more specific about what you might want to search? Just one section, or multiple sections? Will you need to search on one field in the section, or multiple fields? And what types of fields are these?

I can explain the forum SQL above, and how to join multiple sections together, but it’s getting into rather advanced territory that may be beyond what you need.

Since you asked Nick ;)

So far, at least at this point, it is just one section, but I will need to search multiple fields from within the section. The fields are text-input, textarea, and one upload field.

As Carsten mentioned it would be great to have more relevant result, but I would rather just have some type of simple searching (ie: query = dogs, “I like dogs” would be a result)

This is one of those things that I wish was already built into the default ensemble that comes with symphony.

As always thanks Nick!

As Carsten mentioned it would be great to have more relevant result, but I would rather just have some type of simple searching (ie: query = dogs, “I like dogs” would be a result)

Say you have a textarea Description. To filter on dogs add a filter on this field:

regexp:{$url-q}

Then call your Search page as:

/search/?q=dogs

Input and Textarea fields support this “regexp” syntax.

Other examples:

The problem here is that you can filter only on one field. If you add a filter to more than one field, they will combine as an AND, so both will need to match to return an entry. Not great.

I asked Data Source filter: OR across two fields and had the excellent answer of using the Reflection Field. This is basically a text field whose value is built dynamically when the entry is saved. Using XPath you define the data to concatenate together to populate this field. Therefore if you want to search Title (input), Description (textarea) and filename (file upload) you could push these values together into a Reflection field and filter with one regexp:....

More complex, you could like at Sphinx or Lucene

Thanks Nick! Of course, I’ve now been assigned to another project so I will have to circle back later on today to try out what you explained. I’m sure I’ll hit a snag since its another new concept for me.

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