예제 #1
0
TEST(FTSSpec, FixNormalKey1) {
    assertFixSuccess("{key: {a: 'text'}}");
    assertFixSuccess("{key: {a: 'text', b: 'text'}}");
    assertFixSuccess("{key: {a: 'text', b: 'text', c: 'text'}}");

    assertFixFailure("{key: {_fts: 'text'}}");  // not allowed to index reserved field
    assertFixFailure("{key: {_ftsx: 'text'}}");
}
예제 #2
0
TEST(FTSSpec, FixLanguageOverride1) {
    assertFixSuccess("{key: {a: 'text'}, language_override: 'foo'}");
    assertFixSuccess("{key: {a: 'text'}, language_override: 'foo$bar'}");

    assertFixFailure("{key: {a: 'text'}, language_override: 'foo.bar'}");  // can't have '.'
    assertFixFailure("{key: {a: 'text'}, language_override: ''}");
    assertFixFailure("{key: {a: 'text'}, language_override: '$foo'}");
}
예제 #3
0
        TEST( FTSSpec, FixTextIndexVersion1 ) {
            assertFixSuccess("{key: {a: 'text'}, textIndexVersion: 2.0}}");
            assertFixSuccess("{key: {a: 'text'}, textIndexVersion: NumberInt(2)}}");
            assertFixSuccess("{key: {a: 'text'}, textIndexVersion: NumberLong(2)}}");

            assertFixFailure("{key: {a: 'text'}, textIndexVersion: 3}");
            assertFixFailure("{key: {a: 'text'}, textIndexVersion: '2'}");
            assertFixFailure("{key: {a: 'text'}, textIndexVersion: {}}");
        }
예제 #4
0
TEST(FTSSpec, FixWeights1) {
    assertFixSuccess("{key: {a: 'text'}, weights: {}}");
    assertFixSuccess("{key: {a: 'text'}, weights: {a: 1.0}}");
    assertFixSuccess("{key: {a: 'text'}, weights: {a: NumberInt(1)}}");
    assertFixSuccess("{key: {a: 'text'}, weights: {a: NumberLong(1)}}");
    assertFixSuccess("{key: {a: 'text'}, weights: {a: 99999}}");
    assertFixSuccess("{key: {'$**': 'text'}, weights: {'a.b': 2}}");
    assertFixSuccess("{key: {'$**': 'text'}, weights: {a: 2, b: 2}}");
    assertFixSuccess("{key: {'$**': 'text'}, weights: {'$**': 2}}");

    assertFixFailure("{key: {a: 'text'}, weights: 0}");
    assertFixFailure("{key: {a: 'text'}, weights: []}");
    assertFixFailure("{key: {a: 'text'}, weights: 'x'}");
    assertFixFailure("{key: {a: 'text'}, weights: {a: 0}}");
    assertFixFailure("{key: {a: 'text'}, weights: {a: -1}}");
    assertFixFailure("{key: {a: 'text'}, weights: {a: 100000}}");  // above max weight
    assertFixFailure("{key: {a: 'text'}, weights: {a: '1'}}");
    assertFixFailure("{key: {a: 'text'}, weights: {'': 1}}");  // "invalid" path
    assertFixFailure("{key: {a: 'text'}, weights: {'a.': 1}}");
    assertFixFailure("{key: {a: 'text'}, weights: {'.a': 1}}");
    assertFixFailure("{key: {a: 'text'}, weights: {'a..a': 1}}");
    assertFixFailure("{key: {a: 'text'}, weights: {$a: 1}}");
    assertFixFailure("{key: {a: 'text'}, weights: {'a.$a': 1}}");
    assertFixFailure("{key: {a: 'text'}, weights: {'a.$**': 1}}");

    assertFixFailure("{key: {_fts: 'text', _ftsx: 1}, weights: {}}");
    assertFixFailure("{key: {_fts: 'text', _ftsx: 1}}");
}
예제 #5
0
TEST(FTSSpec, FixDefaultLanguage1) {
    assertFixSuccess("{key: {a: 'text'}, default_language: 'english'}");
    assertFixSuccess("{key: {a: 'text'}, default_language: 'engLISH'}");
    assertFixSuccess("{key: {a: 'text'}, default_language: 'en'}");
    assertFixSuccess("{key: {a: 'text'}, default_language: 'eN'}");
    assertFixSuccess("{key: {a: 'text'}, default_language: 'spanish'}");
    assertFixSuccess("{key: {a: 'text'}, default_language: 'none'}");

    assertFixFailure("{key: {a: 'text'}, default_language: 'engrish'}");
    assertFixFailure("{key: {a: 'text'}, default_language: ' english'}");
    assertFixFailure("{key: {a: 'text'}, default_language: ''}");
}
예제 #6
0
TEST(FTSSpec, FixCompoundKey1) {
    assertFixSuccess("{key: {a: 'text', b: 1.0}}");
    assertFixSuccess("{key: {a: 'text', b: NumberInt(1)}}");
    assertFixSuccess("{key: {a: 'text', b: NumberLong(1)}}");
    assertFixSuccess("{key: {a: 'text', b: -1.0}}");
    assertFixSuccess("{key: {a: 'text', b: NumberInt(-1)}}");
    assertFixSuccess("{key: {a: 'text', b: NumberLong(-1)}}");
    assertFixSuccess("{key: {a: 1.0, b: 'text'}}");
    assertFixSuccess("{key: {a: NumberInt(1), b: 'text'}}");
    assertFixSuccess("{key: {a: NumberLong(1), b: 'text'}}");
    assertFixSuccess("{key: {a: -1, b: 'text'}}");
    assertFixSuccess("{key: {a: 1, b: 1, c: 'text'}}");
    assertFixSuccess("{key: {a: 1, b: -1, c: 'text'}}");
    assertFixSuccess("{key: {a: -1, b: 1, c: 'text'}}");
    assertFixSuccess("{key: {a: 1, b: 'text', c: 1}}");
    assertFixSuccess("{key: {a: 'text', b: 1, c: 1}}");
    assertFixSuccess("{key: {a: 'text', b: 1, c: -1}}");
    assertFixSuccess("{key: {a: 'text', b: 'text', c: 1}}");
    assertFixSuccess("{key: {a: 1, b: 'text', c: 'text'}}");

    assertFixFailure("{key: {a: 'text', b: 0}}");
    assertFixFailure("{key: {a: 'text', b: '2d'}}");  // not allowed to mix special indexes
    assertFixFailure("{key: {a: 'text', b: '1'}}");
    assertFixFailure("{key: {a: 'text', _fts: 1}}");
    assertFixFailure("{key: {a: 'text', _fts: 'text'}}");
    assertFixFailure("{key: {a: 'text', _ftsx: 1}}");
    assertFixFailure("{key: {a: 'text', _ftsx: 'text'}}");
    assertFixFailure("{key: {_fts: 1, a: 'text'}}");
    assertFixFailure("{key: {_fts: 'text', a: 'text'}}");
    assertFixFailure("{key: {_ftsx: 1, a: 'text'}}");
    assertFixFailure("{key: {_ftsx: 'text', a: 'text'}}");
    assertFixFailure("{key: {a: 'text', b: 1, c: 'text'}}");  // 'text' must all be adjacent
    assertFixFailure("{key: {a: 'text', b: 1, c: 'text', d: 1}}");
    assertFixFailure("{key: {a: 1, b: 'text', c: 1, d: 'text', e: 1}}");
}