Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -661,9 +661,9 @@ recursive = { git = "https://github.com/datafuse-extras/recursive.git", rev = "1
sled = { git = "https://github.com/datafuse-extras/sled", tag = "v0.34.7-datafuse.1" }
state-machine-api = { git = "https://github.com/databendlabs/state-machine-api.git", tag = "v0.3.4" }
sub-cache = { git = "https://github.com/databendlabs/sub-cache", tag = "v0.2.1" }
tantivy = { git = "https://github.com/datafuse-extras/tantivy", rev = "9065a4d" }
tantivy-common = { git = "https://github.com/datafuse-extras/tantivy", rev = "9065a4d", package = "tantivy-common" }
tantivy-jieba = { git = "https://github.com/datafuse-extras/tantivy-jieba", rev = "ac27464" }
tantivy-query-grammar = { git = "https://github.com/datafuse-extras/tantivy", rev = "9065a4d", package = "tantivy-query-grammar" }
tantivy = { git = "https://github.com/b41sh/tantivy", rev = "48fb0f7f3c393de67a0b46d8a3be50f085312fd4" }
tantivy-common = { git = "https://github.com/b41sh/tantivy", rev = "48fb0f7f3c393de67a0b46d8a3be50f085312fd4", package = "tantivy-common" }
tantivy-jieba = { git = "https://github.com/b41sh/tantivy-jieba", rev = "de314415bdcbf01ab10ab3f76b8eef7cdb6fadf1" }
tantivy-query-grammar = { git = "https://github.com/b41sh/tantivy", rev = "48fb0f7f3c393de67a0b46d8a3be50f085312fd4", package = "tantivy-query-grammar" }
watcher = { git = "https://github.com/databendlabs/watcher", tag = "v0.4.2" }
xorfilter-rs = { git = "https://github.com/datafuse-extras/xorfilter", tag = "databend-alpha.4" }
9 changes: 9 additions & 0 deletions src/query/storages/fuse/src/pruning/inverted_index_pruner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ use std::sync::Arc;
use databend_common_catalog::plan::InvertedIndexInfo;
use databend_common_catalog::plan::PushDownInfo;
use databend_common_exception::Result;
use databend_common_expression::types::DataType;
use databend_common_expression::types::F32;
use databend_storages_common_io::ReadSettings;
use opendal::Operator;
Expand Down Expand Up @@ -95,6 +96,14 @@ impl InvertedIndexPruner {
need_position = true;
}
});
for field_id in &field_ids {
let field = inverted_index_info.index_schema.field(*field_id as usize);
let data_type = field.data_type().remove_nullable();
if data_type == DataType::Variant {
need_position = true;
break;
}
}

// whether need to generate score internl column
let has_score = inverted_index_info.has_score;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -500,6 +500,33 @@ query IT
select * from t2 where query('body:test');
----


statement ok
CREATE TABLE t3 (id int, body variant, INVERTED INDEX idx (body))

statement ok
INSERT INTO t3 VALUES
(1, '{"videoInfo":{"extraData":[{ "name": "codecA", "type": "mp4" },{ "name": "codecB", "type": "jpg" }]}}'),
(2, '{"videoInfo":{"extraData":[{ "name": "codecA", "type": "jpg" },{ "name": "codecA", "type": "mp4" }]}}'),
(3, '{"videoInfo":{"extraData":[{ "name": "codecA", "type": "jpg" },{ "name": "codecB", "type": "mp4" }]}}');

query IT
select * from t3 where query('body.videoInfo.extraData.name:codecA AND body.videoInfo.extraData.type:jpg');
----
2 {"videoInfo":{"extraData":[{"name":"codecA","type":"jpg"},{"name":"codecA","type":"mp4"}]}}
3 {"videoInfo":{"extraData":[{"name":"codecA","type":"jpg"},{"name":"codecB","type":"mp4"}]}}

query IT
select * from t3 where query('body.videoInfo.extraData.name:codecA AND body.videoInfo.extraData.type:mp4');
----
1 {"videoInfo":{"extraData":[{"name":"codecA","type":"mp4"},{"name":"codecB","type":"jpg"}]}}
2 {"videoInfo":{"extraData":[{"name":"codecA","type":"jpg"},{"name":"codecA","type":"mp4"}]}}

query IT
select * from t3 where query('body.videoInfo.extraData.name:codecB AND body.videoInfo.extraData.type:jpg');
----
1 {"videoInfo":{"extraData":[{"name":"codecA","type":"mp4"},{"name":"codecB","type":"jpg"}]}}

statement ok
CREATE TABLE t_native (id int, content string, INVERTED INDEX idx1 (content)) storage_format = 'native' row_per_page = 2;

Expand Down Expand Up @@ -528,3 +555,4 @@ use default
statement ok
drop database test_inverted_index


Loading