@@ -118,7 +118,7 @@ std::vector<std::wstring> LuceneGlobalIndexReader::TokenizeQuery(const std::stri
118118}
119119
120120Lucene::QueryPtr LuceneGlobalIndexReader::ConstructMatchQuery (
121- const std::shared_ptr<FullTextSearch>& full_text_search) const {
121+ const std::shared_ptr<FullTextSearch>& full_text_search) const noexcept ( false ) {
122122 assert (full_text_search->search_type == FullTextSearch::SearchType::MATCH_ALL ||
123123 full_text_search->search_type == FullTextSearch::SearchType::MATCH_ANY );
124124 Lucene::BooleanClause::Occur occur =
@@ -141,7 +141,7 @@ Lucene::QueryPtr LuceneGlobalIndexReader::ConstructMatchQuery(
141141}
142142
143143Lucene::QueryPtr LuceneGlobalIndexReader::ConstructPhraseQuery (
144- const std::shared_ptr<FullTextSearch>& full_text_search) const {
144+ const std::shared_ptr<FullTextSearch>& full_text_search) const noexcept ( false ) {
145145 assert (full_text_search->search_type == FullTextSearch::SearchType::PHRASE );
146146 std::vector<std::wstring> query_terms = TokenizeQuery (full_text_search->query );
147147 auto typed_query = Lucene::newLucene<Lucene::PhraseQuery>();
@@ -152,63 +152,55 @@ Lucene::QueryPtr LuceneGlobalIndexReader::ConstructPhraseQuery(
152152}
153153
154154Lucene::QueryPtr LuceneGlobalIndexReader::ConstructPrefixQuery (
155- const std::shared_ptr<FullTextSearch>& full_text_search) const {
155+ const std::shared_ptr<FullTextSearch>& full_text_search) const noexcept ( false ) {
156156 assert (full_text_search->search_type == FullTextSearch::SearchType::PREFIX );
157157 return Lucene::newLucene<Lucene::PrefixQuery>(Lucene::newLucene<Lucene::Term>(
158158 wfield_name_, LuceneUtils::StringToWstring (full_text_search->query )));
159159}
160160
161161Lucene::QueryPtr LuceneGlobalIndexReader::ConstructWildCardQuery (
162- const std::shared_ptr<FullTextSearch>& full_text_search) const {
162+ const std::shared_ptr<FullTextSearch>& full_text_search) const noexcept ( false ) {
163163 assert (full_text_search->search_type == FullTextSearch::SearchType::WILDCARD );
164164 return Lucene::newLucene<Lucene::WildcardQuery>(Lucene::newLucene<Lucene::Term>(
165165 wfield_name_, LuceneUtils::StringToWstring (full_text_search->query )));
166166}
167167
168168Result<std::shared_ptr<GlobalIndexResult>> LuceneGlobalIndexReader::SearchWithLimit (
169- const Lucene::QueryPtr& query, const std::shared_ptr<FullTextSearch>& full_text_search) const {
169+ const Lucene::QueryPtr& query, const std::shared_ptr<FullTextSearch>& full_text_search) const
170+ noexcept (false ) {
170171 assert (full_text_search->limit );
171- try {
172- Lucene::FilterPtr filter =
173- full_text_search->pre_filter
174- ? Lucene::newLucene<LuceneFilter>(&(full_text_search->pre_filter .value ()))
175- : Lucene::FilterPtr ();
172+ Lucene::FilterPtr filter =
173+ full_text_search->pre_filter
174+ ? Lucene::newLucene<LuceneFilter>(&(full_text_search->pre_filter .value ()))
175+ : Lucene::FilterPtr ();
176176
177- Lucene::TopDocsPtr results =
178- searcher_->search (query, filter, full_text_search->limit .value ());
177+ Lucene::TopDocsPtr results = searcher_->search (query, filter, full_text_search->limit .value ());
179178
180- // prepare BitmapVectorSearchGlobalIndexResult
181- std::map<int64_t , float > id_to_score;
182- for (auto score_doc : results->scoreDocs ) {
183- Lucene::DocumentPtr result_doc = searcher_->doc (score_doc->doc );
184- std::string row_id_str =
185- LuceneUtils::WstringToString (result_doc->get (kRowIdFieldWstring ));
186- std::optional<int32_t > row_id = StringUtils::StringToValue<int32_t >(row_id_str);
187- if (!row_id) {
188- return Status::Invalid (
189- fmt::format (" parse row id str {} to int failed" , row_id_str));
190- }
191- id_to_score[static_cast <int64_t >(row_id.value ())] =
192- static_cast <float >(score_doc->score );
193- }
194- RoaringBitmap64 bitmap;
195- std::vector<float > scores;
196- scores.reserve (id_to_score.size ());
197- for (const auto & [id, score] : id_to_score) {
198- bitmap.Add (id);
199- scores.push_back (score);
179+ // prepare BitmapVectorSearchGlobalIndexResult
180+ std::map<int64_t , float > id_to_score;
181+ for (auto score_doc : results->scoreDocs ) {
182+ Lucene::DocumentPtr result_doc = searcher_->doc (score_doc->doc );
183+ std::string row_id_str = LuceneUtils::WstringToString (result_doc->get (kRowIdFieldWstring ));
184+ std::optional<int32_t > row_id = StringUtils::StringToValue<int32_t >(row_id_str);
185+ if (!row_id) {
186+ return Status::Invalid (fmt::format (" parse row id str {} to int failed" , row_id_str));
200187 }
201- return std::make_shared<BitmapVectorSearchGlobalIndexResult>(std::move (bitmap),
202- std::move (scores));
203- } catch (const std::exception& e) {
204- return Status::Invalid (fmt::format (" visit term query failed, with {} error." , e.what ()));
205- } catch (...) {
206- return Status::UnknownError (" visit term query failed, with unknown error." );
188+ id_to_score[static_cast <int64_t >(row_id.value ())] = static_cast <float >(score_doc->score );
189+ }
190+ RoaringBitmap64 bitmap;
191+ std::vector<float > scores;
192+ scores.reserve (id_to_score.size ());
193+ for (const auto & [id, score] : id_to_score) {
194+ bitmap.Add (id);
195+ scores.push_back (score);
207196 }
197+ return std::make_shared<BitmapVectorSearchGlobalIndexResult>(std::move (bitmap),
198+ std::move (scores));
208199}
209200
210- Result<std::shared_ptr<GlobalIndexResult>> LuceneGlobalIndexReader::SearchWithNoLimit (
211- const Lucene::QueryPtr& query, const std::shared_ptr<FullTextSearch>& full_text_search) const {
201+ std::shared_ptr<GlobalIndexResult> LuceneGlobalIndexReader::SearchWithNoLimit (
202+ const Lucene::QueryPtr& query, const std::shared_ptr<FullTextSearch>& full_text_search) const
203+ noexcept (false ) {
212204 assert (!full_text_search->limit );
213205 Lucene::FilterPtr filter =
214206 full_text_search->pre_filter
0 commit comments