Oracle Contains function usage, oraclecontains

Source: Internet
Author: User

Oracle Contains function usage, oraclecontains

1. query student addresses in Beijing

SELECT student_id,student_nameFROM studentsWHERE CONTAINS( address, 'beijing' )

Remark: beijing is a word that must be enclosed in single quotes.

2. query student addresses in Hebei Province

SELECT student_id,student_nameFROM studentsWHERE CONTAINS( address, '"HEIBEI province"' )

Remark: HEBEI province is a phrase that must be enclosed in double quotation marks.

3. query student addresses in Hebei province or Beijing

SELECT student_id,student_nameFROM studentsWHERE CONTAINS( address, '"HEIBEI province" OR beijing' )

Remark: You can specify logical operators (including AND, and not, OR ).

4. query the addresses with the words "Nanjing Road"

SELECT student_id,student_nameFROM studentsWHERE CONTAINS( address, 'nanjing NEAR road' )

Remark: The above query will return addresses that contain the words "nanjing road", "nanjing east road", and "nanjing west road.
A near B indicates that A is near B.

5. query the address starting with 'hu '.

SELECT student_id,student_nameFROM studentsWHERE CONTAINS( address, '"hu*"' )

Remark: The preceding query returns an address containing the words 'hubei' and 'hunanc.
Remember: *, not %.

6. Weighted queries

SELECT student_id,student_nameFROM studentsWHERE CONTAINS( address, 'ISABOUT (city weight (.8), county wright (.4))' )

Remark: ISABOUT is the keyword of this query. weight specifies a value ranging from 0 ~ The number between 1, similar to the coefficient (I understand ). Indicates that different conditions have different focuses.

7. multi-state query of words

SELECT student_id,student_nameFROM studentsWHERE CONTAINS( address, 'FORMSOF (INFLECTIONAL,street)' )

Remark: The query returns the addresses that contain the words 'street 'and 'streets.
For a verb, different tenses are returned, such as dry, dry, dried, drying, and so on.

8. Word query example

Word query is a query of exact words or phrases between single quotes in the input to the CONTAINS operator. In the following example, all documents with the oracle word in the text column are searched. The scores of each row are selected by the SCORE operator of tag 1:

SELECT SCORE(1) title from news WHERE CONTAINS(text,'oracle',1)> 0;

In a query expression, you can use text operators such as and or to obtain different results. You can also add structural predicates to the WHERE clause. You can use count (*), CTX_QUERY.COUNT_HITS, or CTX_QUERY.EXPLAIN to calculate the number of hit (matching) queries.

9 ABOUT query example

In all languages, ABOUT queries increase the number of related documents returned by a query. In English, ABOUT queries can use the indexed key word component, which is created by default. In this way, the operator returns a document based on the query concept, rather than just the specified exact word or phrase. For example, the following query searches for all documents about the topic politics in the text column, instead of documents containing only the word "politics:

SELECT SCORE(1) title from news WHERE CONTAINS(text, 'about(politics)', 1) > 0;

Summary

The above section describes the usage of the Contains function in Oracle. I hope it will help you. If you have any questions, please leave a message and I will reply to you in a timely manner. Thank you very much for your support for the help House website!

Related Article

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.