airborne12 commented on code in PR #68758:
URL: https://github.com/apache/doris/pull/68758#discussion_r4268338966


##########
be/src/tools/index_tool.cpp:
##########
@@ -185,18 +185,19 @@ void search(lucene::store::Directory* dir, std::string& 
field, std::string& toke
         context->stats = &stats;
         context->io_ctx = &io_ctx;
 
-        ConjunctionQuery conjunct_query(s, context);
-        InvertedIndexQueryInfo query_info;
-        query_info.field_name = field_ws;
-        for (auto& term : terms) {
-            doris::segment_v2::TermInfo term_info;
-            term_info.term = term;
-            query_info.term_infos.push_back(term_info);
+        const doris::index_query::logical::Node leaf {
+                .value = doris::index_query::logical::TermSet {.field = {},
+                                                               .terms = 
split(token, '|'),
+                                                               .require_all = 
true,
+                                                               
.min_should_match = 0}};
+        auto result = std::make_shared<roaring::Roaring>();
+        const doris::Status status = run_clucene_leaf(context, field_ws, leaf, 
nullptr,
+                                                      /*scoring=*/false, s, 
result);
+        if (!status.ok()) {

Review Comment:
   Fixed in f48b3e84753.
   
   `search()` now returns the query status. A failed MATCH_ALL prints no count, 
and `term_query` prints the error and exits with -1, as it does when CLucene 
throws.
   
   Running the tool showed one more problem on this path: MATCH_ALL builds a 
`RuntimeState`, whose constructor registers memory trackers that `index_tool` 
never initialized, so the command crashed before it read the index (master has 
the same code). `term_query` now initializes them, as `meta_tool` does.
   
   Checked on the V1 fixture 
`be/test/storage/test_data/x86_new_1744025019684.idx` with 
`--column_name=request --term=gif`:
   - On the intact file, MATCH_ALL crashed before the change and now reports 
37337 rows, the same as MATCH.
   - On a copy whose `_0.frq` length is set to zero, the dictionary opens and 
the postings read fails. With only the tracker change, the tool printed 
`match_all failed: [E-6002]IndexInput read past EOF`, then `Term queried 
count:0`, and exited 0. With the whole change it prints the error and exits 255.
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to