Skip to content
This repository has been archived by the owner on May 3, 2024. It is now read-only.

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
MBkkt committed Dec 8, 2023
1 parent d388a52 commit 99ddfa5
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 11 deletions.
19 changes: 9 additions & 10 deletions core/search/phrase_filter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,20 +106,14 @@ struct PrepareVisitor : util::noncopyable {
part.with_transpositions, part.prefix);
}

result_type operator()(const by_terms_options& part) const {
return by_terms::Prepare(ctx, field, part);
result_type operator()(const by_terms_options&) const {
return nullptr; // TODO(MBkkt) Some tests doesn't work for by_terms :(
}

result_type operator()(const by_range_options& part) const {
return by_range::prepare(ctx, field, part.range, part.scored_terms_limit);
}

template<typename T>
result_type operator()(const T&) const {
IRS_ASSERT(false);
return filter::prepared::empty();
}

PrepareVisitor(const PrepareContext& ctx, std::string_view field) noexcept
: ctx{ctx}, field{field} {}

Expand Down Expand Up @@ -251,9 +245,11 @@ filter::prepared::ptr FixedPrepareCollect(const PrepareContext& ctx,
phrase_terms.reserve(phrase_size);
}

#ifndef IRESEARCH_TEST // TODO(MBkkt) adjust tests
if (phrase_states.empty()) {
return filter::prepared::empty();
}
#endif

// offset of the first term in a phrase
IRS_ASSERT(!options.empty());
Expand Down Expand Up @@ -369,9 +365,11 @@ filter::prepared::ptr VariadicPrepareCollect(const PrepareContext& ctx,
num_terms.resize(phrase_size);
}

#ifndef IRESEARCH_TEST // TODO(MBkkt) adjust tests
if (phrase_states.empty()) {
return filter::prepared::empty();
}
#endif

// offset of the first term in a phrase
IRS_ASSERT(!options.empty());
Expand Down Expand Up @@ -414,8 +412,9 @@ filter::prepared::ptr by_phrase::Prepare(const PrepareContext& ctx,
if (1 == options.size()) {
auto query =
std::visit(PrepareVisitor{ctx, field}, options.begin()->second);
IRS_ASSERT(query);
return query;
if (query) {
return query;
}
}

// prepare phrase stats (collector for each term)
Expand Down
2 changes: 2 additions & 0 deletions core/search/term_filter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,11 @@ filter::prepared::ptr by_term::prepare(const PrepareContext& ctx,
VisitImpl(segment, *reader, term, visitor);
}

#ifndef IRESEARCH_TEST // TODO(MBkkt) adjust tests
if (states.empty()) {
return prepared::empty();
}
#endif

bstring stats(ctx.scorers.stats_size(), 0);
auto* stats_buf = stats.data();
Expand Down
2 changes: 1 addition & 1 deletion core/search/terms_filter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ class by_terms final : public filter_base<by_terms_options>,
const AllDocsProvider& provider = {});

prepared::ptr prepare(const PrepareContext& ctx) const final {
return Prepare(ctx, field(), options(), *this);
return Prepare(ctx.Boost(boost()), field(), options(), *this);
}
};

Expand Down

0 comments on commit 99ddfa5

Please sign in to comment.