summaryrefslogtreecommitdiff
path: root/src/mongo/db/pipeline/document_internal.h
diff options
context:
space:
mode:
authorEvan Nixon <evan.nixon@10gen.com>2019-05-14 16:05:07 -0700
committerEvan Nixon <evan.nixon@10gen.com>2019-05-14 18:08:39 -0700
commitd6879b6d895a231be17b3adf4bcffa556d05ae17 (patch)
tree24912a9324f4b9a84b02b1e638b6a4027b1a943a /src/mongo/db/pipeline/document_internal.h
parentc83e50d7275adf2a5e946ba2c4b0861fcd9dc69b (diff)
downloadmongo-d6879b6d895a231be17b3adf4bcffa556d05ae17.tar.gz
SERVER-40016 Add searchScore metadata handling
Diffstat (limited to 'src/mongo/db/pipeline/document_internal.h')
-rw-r--r--src/mongo/db/pipeline/document_internal.h19
1 files changed, 18 insertions, 1 deletions
diff --git a/src/mongo/db/pipeline/document_internal.h b/src/mongo/db/pipeline/document_internal.h
index b5030b77693..71b28d2aeb8 100644
--- a/src/mongo/db/pipeline/document_internal.h
+++ b/src/mongo/db/pipeline/document_internal.h
@@ -192,7 +192,8 @@ public:
_metaFields(),
_textScore(0),
_randVal(0),
- _geoNearDistance(0) {}
+ _geoNearDistance(0),
+ _searchScore(0) {}
~DocumentStorage();
@@ -202,6 +203,7 @@ public:
SORT_KEY,
GEONEAR_DIST,
GEONEAR_POINT,
+ SEARCH_SCORE,
// New fields must be added before the NUM_FIELDS sentinel.
NUM_FIELDS
@@ -296,6 +298,9 @@ public:
if (source.hasGeoNearPoint()) {
setGeoNearPoint(source.getGeoNearPoint());
}
+ if (source.hasSearchScore()) {
+ setSearchScore(source.getSearchScore());
+ }
}
bool hasTextScore() const {
@@ -353,6 +358,17 @@ public:
_geoNearPoint = std::move(point);
}
+ bool hasSearchScore() const {
+ return _metaFields.test(MetaType::SEARCH_SCORE);
+ }
+ double getSearchScore() const {
+ return _searchScore;
+ }
+ void setSearchScore(double score) {
+ _metaFields.set(MetaType::SEARCH_SCORE);
+ _searchScore = score;
+ }
+
private:
/// Same as lastElement->next() or firstElement() if empty.
const ValueElement* end() const {
@@ -437,6 +453,7 @@ private:
BSONObj _sortKey;
double _geoNearDistance;
Value _geoNearPoint;
+ double _searchScore;
// When adding a field, make sure to update clone() method
// Defined in document.cpp