diff options
author | Mark Benvenuto <mark.benvenuto@mongodb.com> | 2015-10-26 11:20:12 -0400 |
---|---|---|
committer | Mark Benvenuto <mark.benvenuto@mongodb.com> | 2015-10-26 15:07:07 -0400 |
commit | 1c91d1a2b789fef8be6427de81c35658ff30009d (patch) | |
tree | baf49d48e66a16b774b41b7647f32cd9bbd2e212 /src/mongo/db/matcher | |
parent | 75689917412c571427f12b7fe29a4dfa458d2df3 (diff) | |
download | mongo-1c91d1a2b789fef8be6427de81c35658ff30009d.tar.gz |
Revert "SERVER-20888: Defer $language check to FTSQuery::Parse"
This reverts commit 4c38ff13739e60d33d52b0c944d55249e7d9cc68.
Diffstat (limited to 'src/mongo/db/matcher')
-rw-r--r-- | src/mongo/db/matcher/expression_parser_text.cpp | 7 | ||||
-rw-r--r-- | src/mongo/db/matcher/expression_parser_text_test.cpp | 7 |
2 files changed, 12 insertions, 2 deletions
diff --git a/src/mongo/db/matcher/expression_parser_text.cpp b/src/mongo/db/matcher/expression_parser_text.cpp index d8dd49f4b85..6968dc6c0cb 100644 --- a/src/mongo/db/matcher/expression_parser_text.cpp +++ b/src/mongo/db/matcher/expression_parser_text.cpp @@ -60,8 +60,11 @@ StatusWithMatchExpression expressionParserTextCallbackReal(const BSONObj& queryO "$language requires a string value"); } language = languageElt.String(); - // NOTE: the language parameter is validated during FTSQuery::Parse when we have the index - // spec and know which version of the index to use for the language list + Status status = fts::FTSLanguage::make(language, fts::TEXT_INDEX_VERSION_2).getStatus(); + if (!status.isOK()) { + return StatusWithMatchExpression(ErrorCodes::BadValue, + "$language specifies unsupported language"); + } } string query = queryObj["$search"].String(); diff --git a/src/mongo/db/matcher/expression_parser_text_test.cpp b/src/mongo/db/matcher/expression_parser_text_test.cpp index 5aae8f0acd0..3d51604f7ef 100644 --- a/src/mongo/db/matcher/expression_parser_text_test.cpp +++ b/src/mongo/db/matcher/expression_parser_text_test.cpp @@ -54,6 +54,13 @@ TEST(MatchExpressionParserText, Basic) { ASSERT_EQUALS(textExp->getDiacriticSensitive(), fts::FTSQuery::diacriticSensitiveDefault); } +TEST(MatchExpressionParserText, LanguageError) { + BSONObj query = fromjson("{$text: {$search:\"awesome\", $language:\"spanglish\"}}"); + + StatusWithMatchExpression result = MatchExpressionParser::parse(query); + ASSERT_FALSE(result.isOK()); +} + TEST(MatchExpressionParserText, CaseSensitiveTrue) { BSONObj query = fromjson("{$text: {$search:\"awesome\", $caseSensitive: true}}"); |