zoukankan      html  css  js  c++  java
  • Oracle全文检索学习(一)

    操作系统:windows xp
    Oracle 10g  10.2
    内存:512M
    数据库全装: 必须要用CTXSYS用户.
    以下是建立最简单支持英文的全文检索
    --删除text用户
    Drop User text;

    -- 创建text用户
    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;


    --将CTXAPP用户的权限赋予TEXT用,
    Grant CTXAPP  to  text  with  Admin  Option;


    --将HR用户下的EMPLOREE表和数据拷贝到text用户下
     
    --建立一个preference:( ----设置搜索器类型) 
    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;


    --释放preference
    BEGIN
    ctx_ddl.drop_preference ('main_lexer');
    ctx_ddl.drop_preference ('mywordlist');
    END;

    --浏览自己创造的preference
    SELECT * FROM ctx_user_preferences ;

    --创建索引
    Drop Index myindex;

    --如果不显示的指定索引参数,系统会自动探测文本语言,数据类型和文档格式
    CREATE INDEX myindex ON EMPLOREE(first_name) INDEXTYPE IS CTXSYS.Context;


    /*如上命令建立了一个默认参数的CONTEXT索引myindex.系统默认:
    1. 文本存储在数据库中。可以是CLOB, BLOB, BFILE, VARCHAR2, or CHAR类型的文本数据。
    2. 文本列语言是数据库建立时的默认的字符集。
    3. 使用数据库默认的终止目录stoplist.stoplist记录存在于文本列中但不对其索引的词。
    4. 允许模糊查询。模糊查询阐述用%表示*/

    select * from EMPLOREE where contains(first_name,'D%A%') >0;

  • 相关阅读:
    ppt中调整图片位置
    如何理解 Google Protocol Buffer
    g++: error: unrecognized command line option ‘-std=C++11’
    手把手教你如何加入到github的开源世界!
    redis
    maven
    Spring----注释----开启Annotation <context:annotation-config> 和 <context:component-scan>诠释及区别
    JMX学习笔记(一)-MBean
    Redis学习笔记2-redis管道(pipeline)
    Redis学习笔记1-java 使用Redis(jedis)
  • 原文地址:https://www.cnblogs.com/bobzhangfw/p/768112.html
Copyright © 2011-2022 走看看