diff options
author | Tor Egge <Tor.Egge@broadpark.no> | 2020-06-23 14:28:05 +0200 |
---|---|---|
committer | Tor Egge <Tor.Egge@broadpark.no> | 2020-06-23 14:34:15 +0200 |
commit | a5a3a8effee04aa36c2c6af046df876b488bf980 (patch) | |
tree | 1db6b99ebc619d96636309ce35008b6bb53c5309 | |
parent | 818001352928e28fbd27a86b6aadd640df62850e (diff) |
Disable approximate search in nearest neighbor blueprint
when ratio of candidates in the global filter is too low.
-rw-r--r-- | searchlib/src/vespa/searchlib/queryeval/nearest_neighbor_blueprint.cpp | 5 | ||||
-rw-r--r-- | searchlib/src/vespa/searchlib/queryeval/nearest_neighbor_blueprint.h | 3 |
2 files changed, 3 insertions, 5 deletions
diff --git a/searchlib/src/vespa/searchlib/queryeval/nearest_neighbor_blueprint.cpp b/searchlib/src/vespa/searchlib/queryeval/nearest_neighbor_blueprint.cpp index 3da20603e06..2cf6e7e29c4 100644 --- a/searchlib/src/vespa/searchlib/queryeval/nearest_neighbor_blueprint.cpp +++ b/searchlib/src/vespa/searchlib/queryeval/nearest_neighbor_blueprint.cpp @@ -59,7 +59,6 @@ NearestNeighborBlueprint::NearestNeighborBlueprint(const queryeval::FieldSpec& f _query_tensor(std::move(query_tensor)), _target_num_hits(target_num_hits), _approximate(approximate), - _use_brute_force(false), _explore_additional_hits(explore_additional_hits), _brute_force_limit(brute_force_limit), _fallback_dist_fun(), @@ -101,13 +100,13 @@ NearestNeighborBlueprint::set_global_filter(const GlobalFilter &global_filter) LOG(debug, "set_global_filter getNumDocs: %u / max_hits %u", est_hits, max_hits); double max_hit_ratio = static_cast<double>(max_hits) / est_hits; if (max_hit_ratio < _brute_force_limit) { - _use_brute_force = true; + _approximate = false; LOG(debug, "too many hits filtered out, using brute force implementation"); } else { est_hits = std::min(est_hits, max_hits); } } - if (!_use_brute_force) { + if (_approximate) { est_hits = std::min(est_hits, _target_num_hits); setEstimate(HitEstimate(est_hits, false)); perform_top_k(); diff --git a/searchlib/src/vespa/searchlib/queryeval/nearest_neighbor_blueprint.h b/searchlib/src/vespa/searchlib/queryeval/nearest_neighbor_blueprint.h index 8050d350af5..8656e5b4bf2 100644 --- a/searchlib/src/vespa/searchlib/queryeval/nearest_neighbor_blueprint.h +++ b/searchlib/src/vespa/searchlib/queryeval/nearest_neighbor_blueprint.h @@ -23,7 +23,6 @@ private: std::unique_ptr<vespalib::tensor::DenseTensorView> _query_tensor; uint32_t _target_num_hits; bool _approximate; - bool _use_brute_force; uint32_t _explore_additional_hits; double _brute_force_limit; search::tensor::DistanceFunction::UP _fallback_dist_fun; @@ -45,7 +44,7 @@ public: const vespalib::tensor::DenseTensorView& get_query_tensor() const { return *_query_tensor; } uint32_t get_target_num_hits() const { return _target_num_hits; } void set_global_filter(const GlobalFilter &global_filter) override; - bool may_approximate() const { return _approximate && !_use_brute_force; } + bool may_approximate() const { return _approximate; } std::unique_ptr<SearchIterator> createLeafSearch(const search::fef::TermFieldMatchDataArray& tfmda, bool strict) const override; |