Application of full text retrieval (2)

Source: Internet
Author: User

CONTAINS syntax
We usually use CONTAINS in the WHERE clause, just like this: SELECT * FROM table_name WHERE CONTAINS (fulltext_column, ' Search contents ').

We learn by example, assuming there is a table students, where the address is a full-text retrieved column.
1. Check the address of students in Beijing
SELECT Student_id,student_name
From students
WHERE CONTAINS (address, ' Beijing ')
Remark:beijing is a word that needs to be enclosed in single quotes.

2. Check the residence of students in Hebei province
SELECT Student_id,student_name
From students
WHERE CONTAINS (Address, ' "Heibei province")
Remark:hebei Province is a phrase that is enclosed in double quotes in single quotes.

3. The student who inquires the address in Hebei province or Beijing
SELECT Student_id,student_name
From students
WHERE CONTAINS (Address, ' "Heibei province" OR Beijing ')
Remark: You can specify logical operators (including and, and Not,or).

4. Check the address of the word ' Nanjing Road '
SELECT Student_id,student_name
From students
WHERE CONTAINS (Address, ' Nanjing NEAR Road ')
Remark: The above query will return the address containing the words ' Nanjing Road ', ' Nanjing East Road ' and ' Nanjing West Road '.
A NEAR B is the condition: A is near B.

5. Query the address beginning with ' Lake '
SELECT Student_id,student_name
From students
WHERE CONTAINS (Address, ' "hu*")
Remark: The above query will return the address containing the words ' Hubei ', ' Hunan ' and so on.
Remember is *, not%.

6. A 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 of this query, weight specifies a number between 0~1, a similar coefficient (I understand). It means that different conditions have different emphases.

7. Multi-state query for words
SELECT Student_id,student_name
From students
WHERE CONTAINS (Address, ' formsof (inflectional,street) ')
Remark: The query will return the address containing the words ' street ', ' Streets ' and so on.
For the verb will return its different tenses, such as: dry, will return dry,dried,drying and so on.

The above examples are all in English, do not use Chinese is because some query way Chinese do not support, and my computer is English system

Pay: Query for full text Search 1:

5. The process of updating a full-text index is more time-consuming than regular indexing and is not immediately updated by the database system as a regular index.
That can be updated immediately
9. If you include noise words in your query, an error is raised, and you should remove these noise words in your application.
No, the query will filter out their own noise word, only the content of the query is noise words will only occur when the error

Application of full text retrieval (1)



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.