Oracle full-text search (1)

Source: Internet
Author: User

Operating System: Windows XP
Oracle 10g 10.2
Memory: 512 MB
Full database installation: you must use the ctxsys user.
Below is a simple full-text search that supports English
-- Delete text users
Drop user text;

-- Create a text user
Create user text
Identified by text
Default tablespace users
Temporary tablespace temp;
-- Grant/Revoke role privileges
Grant resource to text with admin option;
Grant connect to text with admin option;

-- Grant the ctxapp user the permission to use text,
Grant ctxapp to text with admin option;

-- Copy the emploree table and data under the HR user to the text user

-- Create a preference :( ---- set the searcher type)
Begin
Ctx_ddl.create_preference ('main _ lexer ', 'Chinese _ lexer ');
Ctx_ddl.create_preference ('mywordlist', 'Basic _ wordlist ');
Ctx_ddl.set_attribute ('mywordlist', 'prefix _ Index', 'true ');
Ctx_ddl.set_attribute ('mywordlist', 'prefix _ min_length ', 1 );
Ctx_ddl.set_attribute ('mywordlist', 'prefix _ max_length ', 5 );
Ctx_ddl.set_attribute ('mywordlist', 'substring _ Index', 'yes ');

End;

-- Release preference
Begin
Ctx_ddl.drop_preference ('main _ lexer ');
Ctx_ddl.drop_preference ('mywordlist ');
End;

-- Browse preference created by myself
Select * From ctx_user_preferences;

-- Create an index
Drop index myindex;

-- If the specified index parameter is not displayed, the system automatically detects the text language, data type, and document format.
Create index myindex on emploree (first_name) indextype is ctxsys. context;

/* The above command creates a default parameter "context Index" myindex. Default Value:
1. Text is stored in the database. It can be clob, blob, bfile, varchar2, or char text data.
2. The text column language is the default character set when the database is created.
3. Use the default database termination directory stoplist. Stoplist to record words that exist in text columns but do not index them.
4. Fuzzy search is allowed. % Indicates the fuzzy search Description */

Select * From emploree where contains (first_name, 'd % A % ')> 0;

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.