PHP word segmentation search sorting by matching quantity

Source: Internet
Author: User
Tags advanced php tutorial
Search for PHP word segmentation by matching quantity. First, the word segmentation function is completed.

For example, if you search for "advanced PHP Tutorial", you can extract "advanced PHP Tutorial"

Now we need to sort by matching quantity. At the same time, the content of all words is ranked first, and the content of two words is ranked second. only one word is ranked last.

How can this function be implemented?


Reply to discussion (solution)

If full-text search is not used, your requirements can be met, but the efficiency is extremely low (joint query)
However, mysql full-text search does not support Chinese characters, so you need to install third-party software.
Third-party software installation usually requires some cost.
Another solution is to store the text after word segmentation into the database in hexadecimal format.
However, this requires at least one more storage space.

Choose Your Own

If full-text search is not used, your requirements can be met, but the efficiency is extremely low (joint query)
However, mysql full-text search does not support Chinese characters, so you need to install third-party software.
Third-party software installation usually requires some cost.
Another solution is to store the text after word segmentation into the database in hexadecimal format.
However, this requires at least one more storage space.

Choose Your Own



Maybe I have not made it clear.

For example, the title of three articles is as follows:
1. download the tutorial
2. download advanced PHP tutorials
3. PHP Tutorial download

I used keywords to search: "advanced PHP Tutorial". the titles of all three articles should be available,
Sort as follows:
1. Download "match to three keywords" in the advanced PHP Tutorial
2. download matching two keywords in the PHP Tutorial
3. Download "match to a keyword" in the tutorial.

Realistic ideas and methods

No where? It does not seem to work, but thanks for the version.

Oh, where is missing
Make it up by yourself. it is meaningless.

You should use full-text indexes in this case.
Coreseek + sphek
Reference: http://www.cnblogs.com/yjf512/p/3581869.html

It seems that word segmentation search is really a pitfall.
I sincerely thank the two moderators for their enthusiastic answers.

Have you solved this problem? I want to solve it now.

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.