I may be missing something blindingly obvious, but simplesearch seems to not work on multiple search terms.
If I search for “Chanel” I get 19 results.
If I search for “Bag” I get 12 results
If I search for “Chanel b” I get 10 results
Then “Chanel ba” or “Chanel bag” gets 0 results
Does simplesearch just not cope with multiple terms? Or is there a setting I’ve missed?
I’ve looked into this further by testing other websites and grav skeletons that use simplesearch. It seems that it will only find adjacent terms, which seems fairly inefficient to me.
For example, on the SoraArticle skeleton, the first article is “Sunshine in the Hills”
If I search for “sunshine” I get the article
If I search for “hills” I also get the article
If I search for “sunshine hills” I get a zero result.
Surely this should work better than this, even for a simple search?
@dan-james, A quick look at the code reveals SimpleSearch does an
explode(',', $query) and removes the page from the page collection if not all substrings from the explode exist in the page.
Meaning: A comma splits the search string and all sub-strings must exist in the page.
So try: “sunshine, hills”
I must admit it is a rather undocumented feature…
You also might want to take a look at TNTSearch which is index based and offers more functionality.
Thanks again pamtbaau! I didn’t spot that - I did have a quick look through the code. These clients won’t be putting commas in so I’ll go for TNTSearch. Thanks for solving that.
It would make sense for simplesearch to explode on a gap - I don’t know anybody who uses commas in search queries anymore… but that’s for another day.
@dan-james, During my quick view I had the same thoughts on the use of commas…
Replacing the comma with space in explode and implode worked fine on first sight by the way.
Thanks - it looked like it should, but I went straight for TNTSearch which is now up and running very smartly. : )
I agree that TNTSearch is probably the better choice for customers searching a vintage catalog.