Oracle全文檢索之Ctxcat 索引
今天測試了Ctxcat 索引,發現也不支援中文分詞。
SQL> Create table auction(Item_id number,Title varchar2(100),Category_id number,Price number,Bid_close date);
Table created
SQL> Insert into auction values(1, 'nikon camera', 1, 400, to_date('24-10-2002','dd-mm-yyyy'));
1 row inserted
SQL> Insert into auction values(2, 'olympus camera', 1, 300, to_date('25-10-2002','dd-mm-yyyy'));
1 row inserted
SQL> Insert into auction values(3, 'pentax camera', 1, 200, to_date('26-10-2002','dd-mm-yyyy'));
1 row inserted
SQL> Insert into auction values(4, 'canon camera', 1, 250, to_date('27-10-2002','dd-mm-yyyy'));
1 row inserted
SQL> Commit;
Commit complete
--建立索引集
SQL> begin
2 ctx_ddl.create_index_set('auction_iset');
3 ctx_ddl.add_index('auction_iset','price'); /* sub-index a*/
4 end;
5 /
PL/SQL procedure successfully completed
--建立索引
SQL> Create index auction_titlex on auction(title) indextype is ctxsys.ctxcat parameters ('index set auction_iset');
Index created
SQL> Column title format a60;
SQL> Select title, price from auction where catsearch(title, 'camera', 'order by price')> 0;
TITLE PRICE
------------------------------------------------------------ ----------
pentax camera 200
canon camera 250
olympus camera 300
nikon camera 400
--測試索引是否自動同步
SQL> Insert into auction values(5, 'aigo camera', 1, 10, to_date('27-10-2002','dd-mm-yyyy'));
1 row inserted
SQL> Insert into auction values(6, 'len camera', 1, 23, to_date('27-10-2002','dd-mm-yyyy'));
1 row inserted
SQL> commit;
Commit complete
SQL> Select title, price from auction where catsearch(title, 'camera','price <= 100')>0;
TITLE PRICE
------------------------------------------------------------ ----------
aigo camera 10
len camera 23
SQL> --新增多個子查詢到索引集:
SQL> begin
2 ctx_ddl.drop_index_set('auction_iset');
3 ctx_ddl.create_index_set('auction_iset');
4 ctx_ddl.add_index('auction_iset','price'); /* sub-index A */
5 ctx_ddl.add_index('auction_iset','price, bid_close'); /* sub-index B */
6 end;
7 /
PL/SQL procedure successfully completed
SQL> drop index auction_titlex;
Index dropped
SQL> Create index auction_titlex on auction(title) indextype is ctxsys.ctxcat parameters ('index set auction_iset');
Index created
SQL> SELECT * FROM auction WHERE CATSEARCH(title, 'camera','price = 200 order by bid_close')>0;
ITEM_ID TITLE CATEGORY_ID PRICE BID_CLOSE
---------- ------------------------------------------------------------ ----------- ---------- -----------
3 pentax camera 1 200 2002/10/26
SQL> SELECT * FROM auction WHERE CATSEARCH(title, 'camera','order by price, bid_close')> 0;
ITEM_ID TITLE CATEGORY_ID PRICE BID_CLOSE
---------- ------------------------------------------------------------ ----------- ---------- -----------
5 aigo camera 1 10 2002/10/27
6 len camera 1 23 2002/10/27
3 pentax camera 1 200 2002/10/26
4 canon camera 1 250 2002/10/27
2 olympus camera 1 300 2002/10/25
1 nikon camera 1 400 2002/10/24
6 rows selected
SQL>
SQL> --測試中文支援
SQL> Insert into auction values(15, '佳能照相機', 1, 3700, to_date('27-10-2002','dd-mm-yyyy'));
1 row inserted
SQL> Insert into auction values(16, '海爾洗衣機', 1, 2300, to_date('27-10-2002','dd-mm-yyyy'));
1 row inserted
SQL> commit;
Commit complete
SQL> SELECT * FROM auction WHERE CATSEARCH(title, '照相機','order by price, bid_close')> 0;
ITEM_ID TITLE CATEGORY_ID PRICE BID_CLOSE
---------- ------------------------------------------------------------ ----------- ---------- -----------
SQL> Select title, price from auction ;
TITLE PRICE
------------------------------------------------------------ ----------
nikon camera 400
olympus camera 300
pentax camera 200
canon camera 250
aigo camera 10
len camera 23
佳能照相機 3700
海爾洗衣機 2300
8 rows selected
SQL>
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/81227/viewspace-692471/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- oracle全文索引之配置全文檢索環境Oracle索引
- Oracle的全文檢索技術(轉)Oracle
- 配置全文檢索
- Oracle:全文索引Oracle索引
- 全文檢索庫 bluge
- Kibana 全文檢索操作
- oracle全文索引之commit與DML操作Oracle索引MIT
- Oracle的全文索引Oracle索引
- 全文檢索的轉義
- solr全文檢索學習Solr
- oracle全文索引之幾個關鍵表Oracle索引
- oracle全文索引之如何實現查詢Oracle索引
- oracle全文索引之同步和優化索引做了什麼Oracle索引優化
- 基於ElasticSearch實現商品的全文檢索檢索Elasticsearch
- openGauss每日一練(全文檢索)
- php + MongoDB + Sphinx 實現全文檢索PHPMongoDB
- PostgreSQL全文檢索-詞頻統計SQL
- 全文檢索技術lucene的demo
- 全文檢索引擎(三)---原理剖析索引
- springboot ElasticSearch 簡單的全文檢索高亮Spring BootElasticsearch
- 【IT老齊072】全文檢索執行原理
- 基於Lucene的全文檢索實踐
- ElasticSearch 實現分詞全文檢索 - 概述Elasticsearch分詞
- IM全文檢索技術專題(四):微信iOS端的最新全文檢索技術優化實踐iOS優化
- Laravel 使用 xunsearch(迅搜)全文檢索引擎Laravel索引
- ElasticSearch 實現分詞全文檢索 - delete-by-queryElasticsearch分詞delete
- 個人部落格分享(Laravel + Vue 元件,支援全文檢索)LaravelVue元件
- Mysql 如何實現全文檢索,關鍵詞跑分MySql
- Oracle OCP(15):分層檢索Oracle
- MySQL索引系列:全文索引MySql索引
- lnmp+coreseek實現站內全文檢索(安裝篇)LNMP
- 讀書筆記:從Lucene到Elasticsearch:全文檢索實戰筆記Elasticsearch
- 沒辦法了,用 MySQL 做全文檢索也挺好的MySql
- 一個線上全文索引BUG的排查:關於類阿拉件數字的分詞與檢索索引分詞
- Oracle索引梳理系列(六)- Oracle索引種類之函式索引Oracle索引函式
- 【搜尋引擎】Solr全文檢索近實時查詢優化Solr優化
- oracle之 反向鍵索引Oracle索引
- 索引的作用、為什麼能提高檢索速度?索引
- Homestead 環境下安裝 Elasticsearch 並使用 scout 進行全文檢索Elasticsearch