Need a little help with a search

I have a product search which search’s the title of the products.
This is set in the query as 'products contains “search query” which works ok.
HOWEVER…
The issues I am having is if there is a product title such as ‘Savage Magazine 223’ you have to get the right order of the title.
What I need it to do is pull out anything that has for example in the the title ‘Savage 223’
Does anyone have any ideas how this can be done.

Here is a link to the site I am working on so you can try it http://2022.thegunnery.com.au/gun-shop-adelaide

I had a similar situation before, I had to use a split on the space and change contains to IN.
@TomD may have a sample of something like this, I think he does this a lot.

just tried that and it broke the search and did not return anything… :frowning:

Can you screenshot your query conditions to show here.

You can use the split formatter in the query filters and use it like: $_GET.filter.split(" ")[0] for the first term, $_GET.filter.split(" ")[1] for the second $_GET.filter.split(" ")[2] for the third etc.
So in the query builder you do:

So this will show all the results containing the first or second or third word of the $_GET.filter string.
It’s up to you to decide how many words to get - 3, 5 or more.

3 Likes

OK that worked with a slight modification :slight_smile: Cheers Buddy

So you need it to match all of the search terms - i see you selected AND? Are you sure you don’t want it to be OR?

No because I only want to return the search from within the title, if I did the or on 223 alone would return 100’s of products.

If you have a look now it is working perfectly and I’ve got to say its bloody quick as well.
http://2022.thegunnery.com.au/gun-shop-adelaide

2 Likes

Looks good, glad its working.

1 Like

cheers for your help, it certainly pointed in the right direction. :slight_smile: