blob: c164db69ba1b64c17d2705a0391db20dc9660203 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include "in_term.h"
#include <vespa/searchlib/fef/itermdata.h>
#include <vespa/searchlib/fef/matchdata.h>
#include <vespa/searchlib/query/tree/term_vector.h>
#include <vespa/vespalib/stllike/hash_set.h>
using search::fef::ITermData;
using search::fef::MatchData;
using search::query::TermVector;
namespace search::streaming {
InTerm::InTerm(std::unique_ptr<QueryNodeResultBase> result_base, const string & index,
std::unique_ptr<TermVector> terms, Normalizing normalize_mode)
: MultiTerm(std::move(result_base), index, std::move(terms), normalize_mode)
{
}
InTerm::~InTerm() = default;
void
InTerm::unpack_match_data(uint32_t docid, const ITermData& td, MatchData& match_data)
{
vespalib::hash_set<uint32_t> matching_field_ids;
HitList hl_store;
std::optional<uint32_t> prev_field_id;
for (const auto& term : _terms) {
auto& hl = term->evaluateHits(hl_store);
for (auto& hit : hl) {
if (!prev_field_id.has_value() || prev_field_id.value() != hit.field_id()) {
prev_field_id = hit.field_id();
matching_field_ids.insert(hit.field_id());
}
}
}
auto num_fields = td.numFields();
for (uint32_t field_idx = 0; field_idx < num_fields; ++field_idx) {
auto& tfd = td.field(field_idx);
auto field_id = tfd.getFieldId();
if (matching_field_ids.contains(field_id)) {
auto handle = tfd.getHandle();
if (handle != fef::IllegalHandle) {
auto tmd = match_data.resolveTermField(tfd.getHandle());
tmd->setFieldId(field_id);
tmd->reset(docid);
}
}
}
}
}
|