Tanya-W commented on code in PR #15823:
URL: https://github.com/apache/doris/pull/15823#discussion_r1068093312


##########
be/src/olap/rowset/segment_v2/inverted_index_reader.cpp:
##########
@@ -17,30 +17,288 @@
 
 #include "olap/rowset/segment_v2/inverted_index_reader.h"
 
-#include "common/status.h"
+#include <CLucene/search/BooleanQuery.h>
+#include <CLucene/search/PhraseQuery.h>
+
+#include "common/config.h"
+#include "gutil/strings/strip.h"
+#include "io/fs/file_system.h"
+#include "olap/key_coder.h"
+#include "olap/rowset/segment_v2/inverted_index_compound_directory.h"
+#include "olap/rowset/segment_v2/inverted_index_compound_reader.h"
+#include "olap/rowset/segment_v2/inverted_index_desc.h"
+#include "olap/tablet_schema.h"
+#include "olap/utils.h"
+#include "runtime/string_value.h"
+#include "util/time.h"
 
 namespace doris {
 namespace segment_v2 {
 
+bool InvertedIndexReader::_is_match_query(InvertedIndexQueryType query_type) {
+    return (query_type == InvertedIndexQueryType::MATCH_ANY_QUERY ||
+            query_type == InvertedIndexQueryType::MATCH_ALL_QUERY ||
+            query_type == InvertedIndexQueryType::MATCH_PHRASE_QUERY);
+}
+
 bool InvertedIndexReader::indexExists(io::Path& index_file_path) {
     bool exists = false;
     RETURN_IF_ERROR(_fs->exists(index_file_path, &exists));
     return exists;
 }
 
+std::vector<std::string> FullTextIndexReader::get_analyse_result(
+        const std::wstring& field_name, const std::wstring& value,
+        InvertedIndexQueryType query_type, InvertedIndexParserType 
analyser_type) {
+    std::vector<std::string> analyse_result;
+    std::shared_ptr<lucene::analysis::Analyzer> analyzer;
+    if (analyser_type == InvertedIndexParserType::PARSER_STANDARD) {
+        analyzer = 
std::make_shared<lucene::analysis::standard::StandardAnalyzer>();
+    } else {
+        // default
+        analyzer = std::make_shared<lucene::analysis::SimpleAnalyzer<TCHAR>>();
+    }
+
+    std::unique_ptr<lucene::util::StringReader> reader(
+            new lucene::util::StringReader(value.c_str()));
+    std::unique_ptr<lucene::analysis::TokenStream> token_stream(
+            analyzer->tokenStream(field_name.c_str(), reader.get()));
+
+    lucene::analysis::Token token;
+
+    while (token_stream->next(&token)) {
+        std::string tk =
+                lucene::util::Misc::toString(token.termBuffer<TCHAR>(), 
token.termLength<TCHAR>());
+        analyse_result.emplace_back(tk);
+    }
+
+    if (token_stream != nullptr) {
+        token_stream->close();
+    }
+
+    if (query_type == InvertedIndexQueryType::MATCH_ANY_QUERY ||
+        query_type == InvertedIndexQueryType::MATCH_ALL_QUERY) {
+        std::set<std::string> unrepeated_result(analyse_result.begin(), 
analyse_result.end());
+        analyse_result.assign(unrepeated_result.begin(), 
unrepeated_result.end());
+    }
+
+    return analyse_result;

Review Comment:
   updated



-- 
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: commits-unsubscr...@doris.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org

Reply via email to