Skip to content

Conversation

@mdianjun
Copy link

@mdianjun mdianjun commented Feb 7, 2022

该PR基于这个代码开发:ClickHouse#19970 (comment) ,它使用的是rust库,而该PR使用的是C++的lucene库。

测试:

//建表:
create table fulltext
(
    `primary_id` UInt64,
    `secondary_id` UInt64,
    `title` String,
    `content` String
)
ENGINE = Lucene();

//插入:
insert into fulltext values(1,10,'nice', 'java'), (2,20,'good', 'cxx'), (3,30,'nice good', 'python');
insert into fulltext values(4,40,'nice good', 'java cxx');
insert into fulltext values(5,50,'good morning', 'good night');
insert into fulltext values(6,60,'abc def ghi', 'abc def ghi jkl');

//基本查询:
select * from fulltext where lucene('title:good +content:python');
select * from fulltext where lucene('title:good content:python');
select * from fulltext where lucene('title:good -content:python');
//表达式分组:
select * from fulltext where lucene('(title:good OR title:nice) AND content:python');
//字段分组:
select * from fulltext where lucene('title:(good nice)');
//短语查询:两个短语之间是OR关系
select * from fulltext where lucene('title:"nice good" content:"java cxx"'); 
//不指定字段名:查所有字段
select * from fulltext where lucene('good'); 
//通配符查询:“?”通配符一个字符,“*”通配多个字符。
select * from fulltext where lucene('py*n'); 
//相似度查询:后边数字表示相似度,默认是5。
select * from fulltext where lucene('pytz~0.2'); 
//距离查询:abc和jkl之间距离2个单词以内。
select * from fulltext where lucene('content:"abc jkl"~2'); 
//范围查询
select * from fulltext where lucene('primary_id:[2 TO 3]'); 
select * from fulltext where lucene('title:{h TO o}');
//权重查询(或叫优先级查询)
select * from fulltext where lucene('title:good^3 OR title:nice');

@Dileep-Dora
Copy link

Any updates on getting the full-text search in Clickhouse?

@HeenaBansal2009
Copy link

@mdianjun , I am looking forward for this feature. Any updates on getting it merge in clickhouse?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants