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;

  • 相关阅读:
    lodash-es 最小化引入
    shortid id生成器
    结构体声明的方式 及类namespace的前置声明
    结构体中使用 箭头 与 点 的区别
    进入Docker容器的几种方式
    协议分析处理工具ProtoBuf
    PubSub ——“发布/订阅”模式
    在Windows/linux下进行gdb调试
    C++中的域作用符::的作用
    C++ 中常用关键字及其用法
  • 原文地址:https://www.cnblogs.com/bobzhangfw/p/768112.html
Copyright © 2011-2022 走看看