Options Available for $searchOptions Array in Multi-Search

6 posts by 3 authors in: Forums > CMS Builder
Last Post: March 15, 2013   (RSS)

By JLynne77 - February 5, 2013 - edited: February 7, 2013

I have a, hopefully, quick question.

For a multi-search, there's this piece of code to put on the list page.

$searchOptions = array();
$searchOptions['keywords'] = @$_REQUEST['q'];
$searchOptions['perPage'] = "10";
$searchOptions['debugSql'] = "0";

I was wondering if there were any other options that could be put in this array and what they were, if they're pre-defined anywhere. Ideally, I was hoping to take 'keywords' and maybe use 'query'. Similar to how the difference between a _keyword search and a _query search work using the URL method for a single table list viewer. Right now, the search returns a massive list of results that I'm hoping to narrow down by allowing someone to add keywords to the search field, like using an 'AND' instead of an 'OR'.

I'm also wondering if there's an "ORDER BY" option. It feels like the results are being displayed in a strange order.

Thanks in advance! :)

-----
~Jessica Sullivan, Crystal Realm Designs.

By JLynne77 - February 7, 2013 - edited: February 7, 2013

Just hoping to get a response. I have a client asking about it for their site, because the results are showing up in a strange place.

If it helps:

http://test.suffolkfcu.org/

If you type in a search for 'savings' with no quotes, the personal savings account page (which is the one most likely to be looked for) doesn't come up until page two. If I add personal or account or even both, it doesn't seem to help narrow the results to that page. Most of the searches seem to be working this way.

-----
~Jessica Sullivan, Crystal Realm Designs.

Hi Jessica,

Sorry for the delay in reply.

The searchMultipleTables function is currently an experimental feature with limited functionality, the only filter option it currently has is for keywords.

The searchMultipleTables function collects results in the order the table items are added to the array. For example:

$searchTables['news'] = array(
  'viewerUrl' => 'multiSearch.php',
  'titleField' => 'title',
  'summaryField' => 'content',
  'searchFields' => array('title','content'),
);

$searchTables['blog'] = array(
  'viewerUrl' => 'multiSearch.php',
  'titleField' => 'title',
  'summaryField' => 'content',
  'searchFields' => array('title','content'),
);


Would collect news results, then blog results. If you reordered them like this:

$searchTables['blog'] = array(
'viewerUrl' => 'multiSearch.php',
'titleField' => 'title',
'summaryField' => 'content',
'searchFields' => array('title','content'),
);

$searchTables['news'] = array(
  'viewerUrl' => 'multiSearch.php',
  'titleField' => 'title',
  'summaryField' => 'content',
  'searchFields' => array('title','content'),
);

Then blog results would be collected first. So I would put sections that people are most likely to want results from at the top of the list, and least likely at the bottom.

There are currently only 4 searchOptions you can use in the searchMultipleTables function, the final one being the orderBy option. You can use this to as you would the orderBy function in a getRecords function. For example:

//NOTE: Because of a bug you always need to have a space at the end of the string.
$searchOptions['orderBy'] = "_title DESC ";

Would return results from each section ordered by there title. 

There is a bug in the orderBy functionality that means you will need to add a space at the end of the string.

Let me know if you have any questions.

Thanks!

Greg

Greg Thomas







PHP Programmer - interactivetools.com

Thanks, Greg. This helps a lot. :)

-----
~Jessica Sullivan, Crystal Realm Designs.

By mdegive - March 15, 2013

I also only would like an additional where clause "where publish=1", is this possible?