I used PHP to perform a simple word segmentation search for the sorting problem of multiple keywords in PHP. Basic functions have been implemented. But there is a small problem. I want to search results. The most matched records are listed first. For example. I searched for the keyword "Chinese people". after word segmentation, the keyword "China" and "people" were obtained. There were three records in the search results. ID1: PHP multi-keyword search sorting in id2.
I used PHP for a simple word segmentation search. Basic functions have been implemented. But there is a small problem.
I want to search results. The most matched records are listed first.
For example. I searched for the keyword "Chinese people". The result after word segmentation is "China", "people ',
There are three records in the search results.
ID1: We have a broad audience in China
ID2 People's Bank of China
People of ID3
I want to sort yes
ID2 People's Bank of China
ID1: We have a broad audience in China
People of ID3
How can this sort be achieved?
------ Solution --------------------
The weight is usually generated based on the search frequency. you can set the weight by yourself, just like the sorting field.
------ Solution --------------------
1. search all results
2. perform regular expression matching as needed. of course, you need to write the regular expression 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.