summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Rassi <rassi@10gen.com>2013-03-12 10:30:21 -0400
committerJason Rassi <rassi@10gen.com>2013-03-12 10:35:53 -0400
commitedb5f4efef0b5592f6e9449db86eca50223439ea (patch)
treef9ecbb4ed83105f4a2edbef871477546f6f68527
parent1b84109f9c0fb976d67de4a837391fbbfbb6659a (diff)
downloadmongo-edb5f4efef0b5592f6e9449db86eca50223439ea.tar.gz
SERVER-8873 Correctly decide if a term in a text field is a stopword
-rw-r--r--src/mongo/db/fts/fts_index_format_test.cpp12
-rw-r--r--src/mongo/db/fts/fts_spec.cpp2
2 files changed, 13 insertions, 1 deletions
diff --git a/src/mongo/db/fts/fts_index_format_test.cpp b/src/mongo/db/fts/fts_index_format_test.cpp
index 7b0f5b32f0a..5ef27dd83f5 100644
--- a/src/mongo/db/fts/fts_index_format_test.cpp
+++ b/src/mongo/db/fts/fts_index_format_test.cpp
@@ -91,6 +91,18 @@ namespace mongo {
ASSERT( i.next().numberDouble() > 0 );
}
+ TEST( FTSIndexFormat, StopWords1 ) {
+ FTSSpec spec( FTSSpec::fixSpec( BSON( "key" << BSON( "data" << "text" ) ) ) );
+
+ BSONObjSet keys1;
+ FTSIndexFormat::getKeys( spec, BSON( "data" << "computer" ), &keys1 );
+ ASSERT_EQUALS( 1U, keys1.size() );
+
+ BSONObjSet keys2;
+ FTSIndexFormat::getKeys( spec, BSON( "data" << "any computer" ), &keys2 );
+ ASSERT_EQUALS( 1U, keys2.size() );
+ }
+
}
}
diff --git a/src/mongo/db/fts/fts_spec.cpp b/src/mongo/db/fts/fts_spec.cpp
index 89a9789f755..009aad2f70e 100644
--- a/src/mongo/db/fts/fts_spec.cpp
+++ b/src/mongo/db/fts/fts_spec.cpp
@@ -216,9 +216,9 @@ namespace mongo {
string term = t.data.toString();
makeLower( &term );
- term = tools.stemmer->stem( term );
if ( tools.stopwords->isStopWord( term ) )
continue;
+ term = tools.stemmer->stem( term );
ScoreHelperStruct& data = terms[term];