示例#1
0
 TEST( FTSMatcher, Phrase2 ) {
     FTSQuery q;
     q.parse( "foo \"table top\"", "english" );
     FTSMatcher m( q,
                   FTSSpec( FTSSpec::fixSpec( BSON( "key" << BSON( "x" << "text" ) ) ) ) );
     ASSERT( m.phraseMatch( "table top",
                            BSON( "x" << BSON_ARRAY( "table top" ) ) ) );
 }
示例#2
0
        TEST( FTSMatcher, NegWild1 ) {
            FTSQuery q;
            q.parse( "foo -bar", "english" );
            FTSMatcher m( q,
                          FTSSpec( FTSSpec::fixSpec( BSON( "key" << BSON( "$**" << "text" ) ) ) ) );

            ASSERT( m.hasNegativeTerm( BSON( "x" << BSON( "y" << "bar" ) ) ) );
            ASSERT( m.hasNegativeTerm( BSON( "x" << BSON( "y" << "bar" ) ) ) );
        }
示例#3
0
        // Regression test for SERVER-11994.
        TEST( FTSMatcher, NegWild2 ) {
            FTSQuery q;
            ASSERT_OK( q.parse( "pizza -restaurant", "english", TEXT_INDEX_VERSION_2 ) );
            FTSMatcher m( q,
                          FTSSpec( FTSSpec::fixSpec( BSON( "key" << BSON( "$**" << "text" ) ) ) ) );

            ASSERT( m.hasNegativeTerm( BSON( "x" << BSON( "y" << "pizza restaurant" ) ) ) );
            ASSERT( m.hasNegativeTerm( BSON( "x" << BSON( "y" << "PIZZA RESTAURANT" ) ) ) );
        }
示例#4
0
        // Test that the matcher parses the document with the document language, not the search
        // language.
        TEST( FTSMatcher, ParsesUsingDocLanguage ) {
            FTSQuery q;
            ASSERT_OK( q.parse( "-glad", "none", TEXT_INDEX_VERSION_2 ) );
            FTSMatcher m( q,
                          FTSSpec( FTSSpec::fixSpec( BSON( "key" << BSON( "x" << "text" ) ) ) ) );

            // Even though the search language is "none", the document {x: "gladly"} should be
            // parsed using the English stemmer, and as such should match the negated term "glad".
            ASSERT( m.hasNegativeTerm( BSON( "x" << "gladly" ) ) );
        }
示例#5
0
        TEST( FTSMatcher, Phrase1 ) {
            FTSQuery q;
            q.parse( "foo \"table top\"", "english" );
            FTSMatcher m( q,
                          FTSSpec( FTSSpec::fixSpec( BSON( "key" << BSON( "$**" << "text" ) ) ) ) );
            
            ASSERT( m.phraseMatch( "table top", BSON( "x" << "table top" ) ) );
            ASSERT( m.phraseMatch( "table top", BSON( "x" << " asd table top asd" ) ) );
            ASSERT( !m.phraseMatch( "table top", BSON( "x" << "tablz top" ) ) );
            ASSERT( !m.phraseMatch( "table top", BSON( "x" << " asd tablz top asd" ) ) );

            ASSERT( m.phrasesMatch( BSON( "x" << "table top" ) ) );
            ASSERT( !m.phrasesMatch( BSON( "x" << "table a top" ) ) );

        }