Full-text index—CONTAINS syntax_PHP tutorial

WBOY
Release: 2016-07-13 17:02:21
Original
1358 people have browsed it

Full-text index - CONTAINS syntax
We usually use CONTAINS in the WHERE clause, like this: SELECT * FROM table_name WHERE CONTAINS(fullText_column,'search contents').

Let’s learn through examples. Suppose there is a table students, in which address is a column for full-text retrieval.
1. Query students whose address is in Beijing
SELECT student_id,student_name
FROM students
WHERE CONTAINS( address, 'beijing' )
remark: beijing is a word and should be enclosed in single quotes stand up.
2. Query students whose address is in Hebei Province
SELECT student_id,student_name
FROM students
WHERE CONTAINS( address, '"HEIBEI province"' )
remark: HEBEI province is a phrase, Also use double quotes within single quotes.
3. Query students whose addresses are in Hebei Province or Beijing
SELECT student_id,student_name
FROM students
WHERE CONTAINS( address, '"HEIBEI province" OR beijing' )
remark: can be specified Logical operators (including AND, AND NOT, OR).
4. Query the address with the words 'Nanjing Road'
SELECT student_id,student_name
FROM students
WHERE CONTAINS( address, 'nanjing NEAR road' )
remark: The above query will return Addresses containing the words 'nanjing road', 'nanjing east road', 'nanjing west road', etc.
A NEAR B means condition: A is close to B.
5. Query the address starting with '湖'
SELECT student_id,student_name
FROM students
WHERE CONTAINS( address, '"hu*"' )
remark: The above query will return Addresses containing the words 'hubei', 'hunan', etc.
Remember it’s *, not %.
6. Similar weighted query
SELECT student_id,student_name
FROM students
WHERE CONTAINS( address, 'ISABOUT (city weight (.8), county wright (.4))' )
remark: ISABOUT is the keyword for this kind of query, and weight specifies a number between 0 and 1, similar to a coefficient (my understanding). Indicates that different conditions have different emphasis.
7. Polymorphic query of words
SELECT student_id,student_name
FROM students
WHERE CONTAINS( address, 'FORMSOF (INFLECTIONAL,street)' )
remark: The query will return items containing 'street ', 'streets' and other words address.
For a verb, it will return its different tenses, such as: dry, which will return dry, dried, drying, etc.
The above examples are all in English. Chinese is not used because some query methods are not supported in Chinese, and my computer is an English system.


www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/631072.htmlTechArticleFull-text index - CONTAINS syntax We usually use CONTAINS in the WHERE clause, like this: SELECT * FROM table_name WHERE CONTAINS(fullText_column,'search contents'). We...
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template