2 users online. Create an account or sign in to join them.Users

Search

I have a Reflection Field that stores names in a surname, forename format which is searchable from the front end and is used to filter a datasource.

I know that users will search names in many different ways, and I'm wondering what the best regex is to use in the filter to accommodate the following possibilities...

surname, forename
surname forename
forename surname
forename
surname

The separate surname and forename are easy to do, but it's the fact that the name can be entered either way round that is confusing me.

I had a Google around and the best I could find for "words in any order" was

\b(?:word1\W+(?:\w+\W+){1,6}word2|word2\W+(?:\w+\W+){1,6}word1)\b

Problem is I have no idea how to achieve this in the datasource editor, as the parameter is one, not many strings. If anyone has any ideas, or can help me customise the datasource to achieve multi word searching, I'd appreciate it...

Hmm, if you could use a Textarea field I think that it supports fulltext boolean searching (its default filtering mode). That way you could search for "nick dunn" and it'd match "dunn, nick", letting MySQL do the hard work. I think.

Thing is, if you have a forename and surname field, how do you get those into a Textarea field without the magic of the Reflection field?

The reflection field supports fulltext boolean searching, triggered with thesearch: keyword.

Jonas, you are a lovely person for pointing that out.

Now on another note.

I have a standard Text Input field set up, and I'm filtering that in a DS by

regexp: {$url-keywords}

$url-keywords is also a required parameter on the DS. I have a record in the section called "Allegoria" which is in the field in question.

When I do this on the front end, no results are returned.

I have just removed the $url-keywords from being required, and not passed any url-keywords in the front end, and I get this in the XML:

<error>MySQL Error (1139): Got error 'empty (sub)expression' from regexp in query "SELECT SQL_CACHE `e`.id,
                        `e`.section_id, e.`author_id`,
                        UNIX_TIMESTAMP(e.`creation_date`) AS `creation_date`
                FROM `sym_entries` AS `e`

                    LEFT JOIN
                        `sym_entries_data_4` AS t4_1
                        ON (e.id = t4_1.entry_id)
                LEFT OUTER JOIN `sym_entries_data_4` AS `ed` ON (`e`.`id` = `ed`.`entry_id`) 
                WHERE 1

                AND `e`.`section_id` = '2' 

                    AND (
                        t4_1.value REGEXP ''
                        OR t4_1.handle REGEXP ''
                    )

                ORDER BY `ed`.`value` ASC"</error>

What if you explode the string and run 2 different searches? Then show the item that was matched in both queries? Or would that be too complicated?

The reflection field supports fulltext boolean searching, triggered with thesearch: keyword.

Woop! That's awesome.

Hrm yes, SQL doesn't like it when you don't pass a valid regex. If your filter value was simply:

{$url-keywords}

Then Symphony does its thing of ignoring the filter entirely when {$url-keywords} doesn't evaluate to a value. But I suppose when your filter is:

regexp: {$url-keywords}

Then event when the param isn't set, the filter evaluates to:

regexp: 

And Symphony thinks it has a value, so doesn't ignore it. Or something.

So I think within the buildDSRetrievalSQL method, when the regex is parsed from the string, there should be a check to ensure that it is actually a regex and not an empty string.

The short term hack would be to customise your DS. Inside grab(), before the DS runs, check the value of {$url-keywords} and if it isn't set, then unset($this->dsParamFILTERS[your-field-id]), to remove the filter yourself.

Hrmph.

Bug. Nuff said. ;) I'll log it...

The problem still remains that it should return 1 result, as logically the regexp is matching the entry in the section, so should return.

See attached...

Attachments:
Screen shot 2011-07-08 at 16.38.42.png, Screen shot 2011-07-08 at 16.37.03.png and Screen shot 2011-07-08 at 16.36.15.png

Does it matter that there's a space between regexp: and your param in the filter?

?profile and then view the list of queries, find the query that's doing the regexp. What does it look like?

I'll have to check that tomorrow, I'm popping into the office anyway...

I'm currently running into exact same problem (with 2.2.5). Any solutions?

What about regexp:{$url-keywords:*}. If $url-keywords doesn't exist, * will be used instead, where * is whatever you like. Should work?

Just tried @brendo's proposal. The search expression should rather be regexp:{$url-keywords:.}.

Sorry for hijacking this thread, but I also have a regexp filtering question:

See http://symphony-cms.com/discuss/thread/86970/

Create an account or sign in to comment.

Symphony • Open Source XSLT CMS

Server Requirements

  • PHP 5.2 or above
  • PHP's LibXML module, with the XSLT extension enabled (--with-xsl)
  • MySQL 5.0 or above
  • An Apache or Litespeed webserver
  • Apache's mod_rewrite module or equivalent

Compatible Hosts

Sign in

Login details