You are here:  » Search Multiple Words


Search Multiple Words

Submitted by stew on Tue, 2016-01-26 23:07 in

Hi David,

Hope all's well, apologies if this is covered in the forum, have been looking through threads. I know also we've looked at it before, but as using plugin not sure if it's different here.

I'm trying to show products for multiple search terms (development site: {link saved), for example:

[pto search="jumper,vest,shirt"]

thus to show results for any product containing the words:

jumper or vest or shirt

at the moment all three have to be present in the product title for results to show,

any ideas on this?

Many Thanks,

Stew

Submitted by support on Wed, 2016-01-27 09:22

Hi Stew,

No problem - to convert the basic search method to logic OR, edit pto_search.php and look for the following code at line 222:

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

...and REPLACE with:

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

Cheers,
David.
--
PriceTapestry.com

Submitted by stew on Wed, 2016-01-27 20:04

Hi David,

That's brilliant - many thanks for that - is much appreciated,

Will try now,

Thanks,

Submitted by stew on Wed, 2016-01-27 20:17

Hi David,

Have just implemented the code into pto_search.php and the search still seems to operate with searching for all words instead of OR,

Any ideas of anything else that might need changing?

Many Thanks,

Submitted by support on Thu, 2016-01-28 09:03

Hello Stew,

Ah - the query would in fact be triggering a FULLTEXT search since all words are > 3 characters and not stopwords, and FULLTEXT is logic OR by default (unless modified to use BOOLEAN MODE) however for a niche site it might be that some words are excluded due to the FULLTEXT frequency rules. Some users find basic search works better in some circumstances so to give that ago, on the configuration page (wp-admin > Settings > PriceTapestry.org) change $config_useFullText to FALSE in the drop down box.

Hope this helps, if still not returning results as expected let me know and i'll check it out further with you...

Cheers,
David.
--
PriceTapestry.com

Submitted by stew on Tue, 2016-02-02 22:26

Hi David,

Thank you for going through that, is really helpful.

Great - I changed the $config_useFullText to FALSE to results are spot on now by the looks of it,

Many Thanks,

Stew

Submitted by stew on Wed, 2016-11-02 12:49

Hi David,

Hope all well, have been using full text searches on the site for a while now, for example:

[pto search="ft:bra,-brief"]

But for some reason they have stopped working, products are being displayed but results are random, the exact same results being shown no matter what the short code is.

Any ideas what could be doing this and how to fix?

Many Thanks,

Stew

Submitted by support on Wed, 2016-11-02 13:19

Hi Stew,

I just checked the last version of pto_search.php from our email and I notice that ft: is being handled by the indexed fields section as a result of the following code beginning at line 177:

    case "ft":
      $fields = array("merchant","category","brand","gender","ft");

If you REPLACE that with just:

      $fields = array("merchant","category","brand","gender");

(the main change is to remove the case "ft":) ft:[expression] searches / shortcodes should then be handled by the ft: handler which begins at line 210...

Hope this helps!

Cheers,
David.
--
PriceTapestry.com

Submitted by stew on Thu, 2016-11-03 10:41

Hi David,

Many thanks for that, it's odd have looked in the live pto_search.php and the code is:

case "brand":
$fields = array("merchant","category","brand");
$first = TRUE;

I've just emailed you the php file,

Will see what you think

Many Thanks,

Stew

Submitted by stew on Fri, 2016-11-04 08:55

Hi David,

Many thanks for updating the pto_search.php file, that now works great.

The only thing is on pages where I had a shortcode such as:

[pto search="gender:male:brief"]

this now doesn't return any results,

Any ideas how I can make a full text search and gender search both work?

for example:

[pto search="ft:bra,-brief"]
and
[pto search="gender:male:brief"]

Many thanks,

Stew

Submitted by support on Fri, 2016-11-04 10:01

Hello Stew,

I'm not sure that is actually in the latest version sent yesterday, so you can re-apply it by editing pto_search.php and look for the following code at line 175:

    case "brand":
      $fields = array("merchant","category","brand");

...and REPLACE with:

    case "brand":
    case "gender":
      $fields = array("merchant","category","brand","gender");

Hope this helps!

Cheers,
David.
--
PriceTapestry.com

Submitted by stew on Fri, 2016-11-04 15:10

Hi David,

Thanks for that, have changed the pto_search.php but still getting no results for:

[pto search="gender:male:brief"]

any ideas?

Will mail you the pto_search.php file now,

Many Thanks,

Stew

Submitted by stew on Thu, 2016-11-10 12:20

Hi David,

Many thanks for looking at that - all working.

One thing though is now getting an error message on brand searches. For example, with a search like:

[pto search="brand:Andrew Christian"]

Am getting an error message:

--

Notice: Array to string conversion in /home/mysite/public_html/wp-content/plugins/pto/pto_search.php on line 716

Notice: Array to string conversion in /home/mysite/public_html/wp-content/plugins/pto/pto_search.php on line 716

Notice: Array to string conversion in /home/mysite/public_html/wp-content/plugins/pto/pto_search.php

--

and then the products appear it below OK.

Any ideas how to remove the error message?

Thanks,

Stew

Submitted by support on Thu, 2016-11-10 13:09

Hello Stew,

That's because of the conversion to multiple select filters in your modified pto_search.php - to correct, look for the following code beginning at line 713:

      if (
         ($pto_sort == "relevance")
         &&
         ($pto_minPrice.$pto_maxPrice.$pto_merchantFilter.$pto_categoryFilter.$pto_brandFilter == "")
         )

...and REPLACE with:

      if (
         ($pto_sort == "relevance")
         &&
         ($pto_minPrice.$pto_maxPrice == "")
         &&
         (count($pto_merchantFilter)+count($pto_categoryFilter)+count($pto_brandFilter) == 0)
         )

Cheers,
David.
--
PriceTapestry.com

Submitted by stew on Thu, 2016-11-10 16:51

Hi David,

Many thanks - implemented that and errors all gone - great,

Have a good weekend,

Thanks