You are here:  » more search terms

Support Forum



more search terms

Submitted by paullas on Tue, 2008-12-30 17:47 in

hi david

i am currently using the below to bring certain search to certain pages

<?php
  $common_baseHREF 
"http://www.example.com/pricetapestry/";
  
$common_path "/path/to/pricetapestry/";
  
$_GET["q"] = "Search Terms";
  require(
$common_path."searchExternal.php");
?>

is it possible to have multiple search times like

<?php
  $common_baseHREF 
"http://www.example.com/pricetapestry/";
  
$common_path "/path/to/pricetapestry/";
  
$_GET["q"] = "Search Terms, more search terms, better terms, great search terms";
  require(
$common_path."searchExternal.php");
?>

thanks

paul

Submitted by support on Wed, 2008-12-31 09:27

Hi Paul,

That should work fine if all keywords are greater than 3 characters; if not, the basic search method will be used which performs an AND search as it stands; however you can change this easily by looking for the following code in your searchExternal.php:

$where = implode(" AND ",$wheres);

...and replacing this with:

$where = implode(" OR ",$wheres);

...but for the best results - stick with all terms > 3 characters if possible!

Cheers,
David.

Submitted by Paul1107 on Fri, 2010-08-20 08:35

Hi David,

I have tried the above in V2 of PT, but it doesn't seem to have worked, my issue is described below.

To illustrate the point My example is in the following url: http://www.menstshirts.org.uk/shop-mens-t-shirts/mens-t-shirts/

The search term I've used is $_GET["q"] = "t shirt";, but as you can see the search picks up all shirts. without doing mapped cats, which may screw the search for other products pages, is there another method you would suggest to get the desired results?

Regards

Paul

Submitted by support on Fri, 2010-08-20 08:56

Hi Paul,

For "t shirt" specifically I think it's going to be best to implement an exact match operator. In the relevant external.php (based on the last version I sent to you), look for the following code at around line 370:

      case "bw":

...and then insert the following new code immediately BEFORE that line:

      case "exact":
        $where = "name LIKE '%".database_safe($parts[1])."%'";
        $sql = "SELECT * , MIN( price ) AS minPrice, MAX( price ) AS maxPrice, COUNT( id ) AS numMerchants FROM `".$config_databaseTablePrefix."products` WHERE ".$where.$priceWhere." GROUP BY name";
        $sqlResultCount = "SELECT COUNT(DISTINCT(name)) as resultcount FROM `".$config_databaseTablePrefix."products` WHERE ".$where.$priceWhere;
        $orderBySelection = $orderByDefault;
        break;

You can then use

  $_GET["q"] = "exact:t shirt";,

...in your calling code.

Hope this helps!

Cheers,
David.
--
PriceTapestry.com

Submitted by Paul1107 on Fri, 2010-08-20 09:20

Thanks David,

Can I confirm with you that it would revert to normal without using the "exact:"?

cheers!

Paul

Submitted by support on Fri, 2010-08-20 09:39

Hi Paul,

That's right - the above won't have any impact on normal search which will just be as before if not using exact:

Cheers,
David.
--
PriceTapestry.com

Submitted by Paul1107 on Fri, 2010-08-20 10:51

Hi david,

made the mod you suggested, but nothing is displayed?

{link saved}

Any suggestions Please?

Cheers

Paul

Submitted by support on Fri, 2010-08-20 12:08

Hi Paul,

Will follow up by email...

Cheers,
David.
--
PriceTapestry.com

Submitted by kimarie on Sat, 2010-08-21 15:28

I tried this with the phrases denim hotpants and denim shorts but no results were found eventhough there are results when just searching one term.

Submitted by support on Sun, 2010-08-22 06:26

Hi kimarie,

Did you add the exact: modification described above? I've asked for your search.php regarding this thread so I'll check this for you at the same time...

Cheers,
David.
--
PriceTapestry.com

Submitted by kimarie on Fri, 2010-10-08 23:02

What exactly do you need to type in the calling code to get the script to search for 2 search terms? I have tried all kinds of combinations but no results ever show?

Submitted by support on Sat, 2010-10-09 09:38

Hi,

By default the search is either logical AND (if normal search method is used) or relevance if full text is used (all words in the query > 3 characters), however it is easy to change both methods to be logical OR if you would prefer. Referring to searchExternal.php, look for the following code at line 209:

  $where = "MATCH ".$matchFields." AGAINST ('".database_safe($parts[0])."')";

...and REPLACE with:

  $match = "+".str_replace(" "," +",$parts[0]);
  $where = "MATCH ".$matchFields." AGAINST ('".database_safe($parts[0])."' IN BOOLEAN MODE)";

Next, look for the following code at line 247:

  $where = implode(" AND ",$wheres);

...and REPLACE with:

  $where = implode(" OR ",$wheres);

Hope this helps!

Cheers,
David.
--
PriceTapestry.com

Submitted by GemViper on Mon, 2011-07-18 16:42

Is there a page where you give search syntax examples?

Scenario: I want to use searchexternal to display muffler systems by either Yoshimura or Sparks.

under that scenario neither AND or OR do the job.

I've tried:
(yoshimura sparks) muffler system = if any word is in the title it returns, ie: ignition system, speaker system etc.
Yoshimura muffler system, sparks muffler system = same as above
Yoshimura, sparks +muffler +system = same as above

I really need to be able to have some terms be mandatory and others be either/or in the same search, having negative words at the same time would also be a help.

Surely there is a syntax that will do the above ?

Submitted by support on Mon, 2011-07-18 21:53

Hi Gem,

Sure, bear with me and tomorrow I'll work out the changes required to support MySQL's full boolean mode searches - it should be straight forward but I need to work through the best way to represent + and - in the query as + in particular has special meaning. I'll check it out on my test server and post the changes required...

Cheers,
David.
--
PriceTapestry.com

Submitted by support on Tue, 2011-07-19 07:25

Hi Gem,

For the most flexibility I think the best approach is to pass an un-normalised $q variable as the match parameter IN BOOLEAN MODE, which will give you the full flexibility as described here.

Firstly, look for the following code at line 6 of search.php

  $q = (isset($_GET["q"])?tapestry_normalise($_GET["q"],":\."):"");

...and REPLACE with:

  $q = (isset($_GET["q"])?$_GET["q"]:"");

Then, look for the following code at line 155 (11/09A) or 215 (12/10A/B):

  $where = "MATCH ".$matchFields." AGAINST ('".database_safe($parts[0])."')";

...and REPLACE with:

  $where = "MATCH ".$matchFields." AGAINST ('".database_safe($q)."' IN BOOLEAN MODE)";

Because of the way certain characters have special meanings in URLs, the best way to construct your queries will be using the search form as normal (as the form submit process will correct URL encode + characters etc.), and then if you wish to hard code links to those search results copy the /search.php?q=... link from the URL and paste that exactly into your code as the href attribute of your hard coded links.

If you're not sure at all how to construct a logical full text query to return the results you're after based on the page linked to above let me know and I'll take a look...

Hope this helps!

Cheers,
David.
--
PriceTapestry.com