N
N
nikkon822018-09-16 12:37:11
opencart
nikkon82, 2018-09-16 12:37:11

How to make the search on the site logical?

Good afternoon.
Can you tell me why the search might not work correctly?
An example on the site is the product Ridan HH No. 14.
When searching for Ridan nn 14 - everything is fine.
But when you enter Ridan 14 - writes that nothing was found.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
T
ThunderCat, 2018-09-16
@ThunderCat

Firstly, denormalize the database, create a search field where the name and description will be combined, and create an index on it.
Secondly, split the query by spaces and look for the final result as (conditionally)

select * from products as pd
where `searchname` like '%$words[0]%' 
and `searchname` like '%$words[1]%'
and `searchname` like '%$words[2]%'

PS: dop_name, opis_name, seriya_nasos - burn in hell.

A
Antonio Solo, 2018-09-17
@solotony

usematch against

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question