PHP multi-keyword search sorting problem
I used PHP to do a simple word search. Basic functionality has been implemented. But there was a small problem.
I want to be in the search results. The most matched records are in front.
For example. I search ' Chinese people ' this keyword, the result of participle is ' China ', ' people ',
There are three records in the search results.
ID1 the vast masses of our Chinese people
ID2 People's Bank
ID3 Masses
I hope the sort is
ID2 People's Bank
ID1 the vast masses of our Chinese people
ID3 Masses
How can we achieve such a sort?
------Solution--------------------
Need to have weights, generally based on the frequency of search, you can also set your own, just like the sort field
------Solution--------------------
1. Search all the results
2. Regular matching as needed of course, regular rules require you to write perfectly.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.