问题描述
大家好,
我使用CTXRULE对一些文本进行分类,但是AB & B工作而AT&T不工作。请在这方面支持我:
这是我的搜索文本
我如何创建索引
这很管用
这不起作用
谢谢。
我使用CTXRULE对一些文本进行分类,但是AB & B工作而AT&T不工作。请在这方面支持我:
这是我的搜索文本
SQL> select text from test_lexer_special;
TEXT
--------------------
AB&B
{AT&T}
AT&T
SQL>我如何创建索引
SQL> EXEC CTX_DDL.CREATE_INDEX_SET('test_ctxrule_1');
PL/SQL procedure successfully completed.
SQL> EXEC CTX_DDL.CREATE_PREFERENCE ('testmy_lexer', 'BASIC_LEXER');
PL/SQL procedure successfully completed.
SQL> EXEC CTX_DDL.SET_ATTRIBUTE ('testmy_lexer', 'PRINTJOINS', '&');
PL/SQL procedure successfully completed.
SQL> CREATE INDEX test_ctxrule_index1 ON test_lexer_special (text)
2 INDEXTYPE IS CTXSYS.CTXRULE
3 PARAMETERS ('INDEX SET test_ctxrule_1 LEXER testmy_lexer STOPLIST CTXSYS.EMPTY_STOPLIST');
Index created.
SQL>这很管用
SQL> SELECT * FROM test_lexer_special WHERE MATCHES(text, 'ab&b')> 0; TEXT -------------------- AB&B SQL>
这不起作用
SQL> SELECT * FROM test_lexer_special WHERE MATCHES(text, 'at&t')> 0;
no rows selected
SQL> select token_text,token_extra from DR$test_ctxrule_index1$I;
TOKEN_TEXT TOKEN_EXTRA
-------------------- --------------------
AB {B}
SQL> 谢谢。
专家解答
AT仍然是停止名单的一部分!您可以通过使用ctx_report.describe_index报告索引来看到这一点:
那么为什么会发生这种情况?你指定了一个空的停止名单,对吗?
你还指定了一个索引集。这些仅适用于CTXCAT索引。你正在使用CTXRULE。不幸的是,这不会引发异常...
单独指定停止列表,一切都将是hunky dory:
create table test_lexer_special (
text varchar2(30)
);
set define off
insert into test_lexer_special values ('AB&B');
insert into test_lexer_special values ('{AT&T}');
insert into test_lexer_special values ('AT&T');
CREATE INDEX test_ctxrule_index1 ON test_lexer_special (text) INDEXTYPE IS CTXSYS.CTXRULE
PARAMETERS ('INDEX SET test_ctxrule_1 LEXER testmy_lexer STOPLIST CTXSYS.EMPTY_STOPLIST');
set long 2000000000
set head off
set pagesize 10000
select ctx_report.describe_index('TEST_CTXRULE_INDEX1') from dual;
===========================================================================
INDEX DESCRIPTION
===========================================================================
index name: "CHRIS"."TEST_CTXRULE_INDEX1"
index id: 1284
index type: ctxrule
base table: "CHRIS"."TEST_LEXER_SPECIAL"
primary key column:
text column: TEXT
text column type: VARCHAR2(30)
language column:
format column:
charset column:
configuration column:
Query Stats Enabled: NO
status: INDEXED
full optimize token:
full optimize count:
docid count: 3
nextid: 4
===========================================================================
INDEX OBJECTS
===========================================================================
datastore: DIRECT_DATASTORE
filter: NULL_FILTER
section group: NULL_SECTION_GROUP
lexer: BASIC_LEXER
wordlist: BASIC_WORDLIST
stemmer: ENGLISH
fuzzy_match: GENERIC
stoplist: BASIC_STOPLIST
stop_word: Mr
stop_word: Mrs
stop_word: Ms
stop_word: a
stop_word: all
stop_word: almost
stop_word: also
stop_word: although
stop_word: an
stop_word: and
stop_word: any
stop_word: are
stop_word: as
stop_word: at
... etc. ...那么为什么会发生这种情况?你指定了一个空的停止名单,对吗?
你还指定了一个索引集。这些仅适用于CTXCAT索引。你正在使用CTXRULE。不幸的是,这不会引发异常...
单独指定停止列表,一切都将是hunky dory:
drop INDEX test_ctxrule_index1;
CREATE INDEX test_ctxrule_index1 ON test_lexer_special (text) INDEXTYPE IS CTXSYS.CTXRULE
PARAMETERS ('STOPLIST CTXSYS.EMPTY_STOPLIST');
SELECT * FROM test_lexer_special WHERE MATCHES(text, 'at&t',1)> 0;
TEXT
{AT&T}
AT&T 「喜欢这篇文章,您的关注和赞赏是给作者最好的鼓励」
关注作者
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。




