-
Notifications
You must be signed in to change notification settings - Fork 614
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #33156 from vespa-engine/geirst/filter-threshold-p…
…er-index-field Support filter threshold setting per index field in an index environm…
- Loading branch information
Showing
9 changed files
with
174 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. | ||
|
||
#pragma once | ||
|
||
namespace search::fef { | ||
|
||
/** | ||
* Class representing the threshold of whether a field should be considered a filter or not during query evaluation. | ||
* | ||
* Some fields are always considered filters, while others are only considered filters | ||
* if the relative document frequency of the term searching the field is above the specified threshold. | ||
*/ | ||
class FilterThreshold { | ||
private: | ||
// A number in the range [0.0, 1.0] encapsulating whether a field should be considered a filter or not. | ||
float _threshold; | ||
|
||
public: | ||
FilterThreshold() noexcept : _threshold(1.0) { } | ||
FilterThreshold(bool is_filter_in) noexcept : _threshold(is_filter_in ? 0.0 : 1.0) { } | ||
FilterThreshold(float threshold) noexcept : _threshold(threshold) { } | ||
FilterThreshold(double threshold) noexcept : _threshold(threshold) { } | ||
float threshold() const noexcept { return _threshold; } | ||
bool is_filter() const noexcept { return _threshold == 0.0; } | ||
|
||
/** | ||
* Returns whether this is considered a filter for a query term with the given relative document frequency (in the range [0.0, 1.0]). | ||
*/ | ||
bool is_filter(float rel_doc_freq) const noexcept { return rel_doc_freq > _threshold; } | ||
}; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters