summaryrefslogtreecommitdiff
path: root/src/mongo/db/fts/fts_spec.cpp
diff options
context:
space:
mode:
authorJason Rassi <rassi@10gen.com>2014-02-28 13:16:04 -0500
committerJason Rassi <rassi@10gen.com>2014-02-28 13:50:59 -0500
commitb6bcdd964c0a45348273fb5d61763d15a8ddcb3a (patch)
tree965f1417c7afe041493222547223016c50c9f96a /src/mongo/db/fts/fts_spec.cpp
parent4d51c9ac8769223b5c2db1383325318d31f141b6 (diff)
downloadmongo-b6bcdd964c0a45348273fb5d61763d15a8ddcb3a.tar.gz
SERVER-10879 Text index builds validate both "key" and "weights"
Diffstat (limited to 'src/mongo/db/fts/fts_spec.cpp')
-rw-r--r--src/mongo/db/fts/fts_spec.cpp34
1 files changed, 18 insertions, 16 deletions
diff --git a/src/mongo/db/fts/fts_spec.cpp b/src/mongo/db/fts/fts_spec.cpp
index 453038473c9..8ad22119a90 100644
--- a/src/mongo/db/fts/fts_spec.cpp
+++ b/src/mongo/db/fts/fts_spec.cpp
@@ -369,22 +369,6 @@ namespace mongo {
"weight for text index needs numeric type",
e.isNumber() );
m[e.fieldName()] = e.numberInt();
-
- // Verify weight refers to a valid field.
- if ( str::equals( e.fieldName(), "$**" ) ) {
- continue;
- }
- FieldRef keyField( e.fieldName() );
- uassert( 17294,
- "weight cannot be on an empty field",
- keyField.numParts() != 0 );
- for ( size_t i = 0; i < keyField.numParts(); i++ ) {
- StringData part = keyField.getPart(i);
- uassert( 17291, "weight cannot have empty path component", !part.empty() );
- uassert( 17292,
- "weight cannot have path component with $ prefix",
- !part.startsWith( "$" ) );
- }
}
}
else if ( spec["weights"].str() == WILDCARD ) {
@@ -400,6 +384,24 @@ namespace mongo {
for ( map<string,int>::iterator i = m.begin(); i != m.end(); ++i ) {
uassert( 16674, "score for word too high",
i->second > 0 && i->second < MAX_WORD_WEIGHT );
+
+ // Verify weight refers to a valid field.
+ if ( i->first != "$**" ) {
+ FieldRef keyField( i->first );
+ uassert( 17294,
+ "weight cannot be on an empty field",
+ keyField.numParts() != 0 );
+ for ( size_t partNum = 0; partNum < keyField.numParts(); partNum++ ) {
+ StringData part = keyField.getPart(partNum);
+ uassert( 17291,
+ "weight cannot have empty path component",
+ !part.empty() );
+ uassert( 17292,
+ "weight cannot have path component with $ prefix",
+ !part.startsWith( "$" ) );
+ }
+ }
+
b.append( i->first, i->second );
}
weights = b.obj();