summaryrefslogtreecommitdiff
path: root/src/mongo/db/fts/fts_spec.h
diff options
context:
space:
mode:
authorJason Rassi <rassi@10gen.com>2013-10-11 21:54:58 -0700
committerJason Rassi <rassi@10gen.com>2013-10-11 21:55:01 -0700
commitbf0f29709b19565245be370aa3f8c46f0332de91 (patch)
tree632455643b23dbb7d24c1964facddf8e2b420b85 /src/mongo/db/fts/fts_spec.h
parente9542d111dcd02f93113ad448ca15a1c9b95f1e7 (diff)
downloadmongo-bf0f29709b19565245be370aa3f8c46f0332de91.tar.gz
SERVER-9390 Text search support for multi-language documents
FTSIndexFormat::getKeys() now desends into subdocuments to find language field to apply to the given subdocument.
Diffstat (limited to 'src/mongo/db/fts/fts_spec.h')
-rw-r--r--src/mongo/db/fts/fts_spec.h41
1 files changed, 26 insertions, 15 deletions
diff --git a/src/mongo/db/fts/fts_spec.h b/src/mongo/db/fts/fts_spec.h
index e867dc04246..d13281eac9f 100644
--- a/src/mongo/db/fts/fts_spec.h
+++ b/src/mongo/db/fts/fts_spec.h
@@ -54,8 +54,13 @@ namespace mongo {
class FTSSpec {
struct Tools {
- Tools( string language )
- : language( language ){}
+ Tools( string _language,
+ const Stemmer* _stemmer,
+ const StopWords* _stopwords )
+ : language( _language )
+ , stemmer( _stemmer )
+ , stopwords( _stopwords ) {}
+
const std::string& language;
const Stemmer* stemmer;
const StopWords* stopwords;
@@ -74,9 +79,26 @@ namespace mongo {
size_t numExtraAfter() const { return _extraAfter.size(); }
const std::string& extraAfter( unsigned i ) const { return _extraAfter[i]; }
- string getLanguageToUse( const BSONObj& userDoc ) const;
+ /**
+ * Find a "language" field, if any, in a given BSON doc. If the language is not on the
+ * list of valid languages, return current.
+ */
+ string getLanguageToUse( const BSONObj& userDoc,
+ const std::string& currentLanguage ) const;
- void scoreDocument( const BSONObj& obj, TermFrequencyMap* scores ) const;
+ /**
+ * Calculates term/score pairs for a BSONObj as applied to this spec.
+ * - "obj": the BSONObj to traverse; can be a subdocument or array
+ * - "parentLanguage": nearest enclosing document "language" spec for obj
+ * - "parentPath": obj's dotted path in containing document
+ * - "isArray": true if obj is an array
+ * - "term_freqs": out-parameter to store results
+ */
+ void scoreDocument( const BSONObj& obj,
+ const string& parentLanguage,
+ const string& parentPath,
+ bool isArray,
+ TermFrequencyMap* term_freqs ) const;
/**
* given a query, pulls out the pieces (in order) that go in the index first
@@ -85,19 +107,8 @@ namespace mongo {
const Weights& weights() const { return _weights; }
- /**
- * @param out - untouched if field isn't present
- * @return if field is here
- */
- bool weight( const StringData& field, double* out ) const;
-
-
static BSONObj fixSpec( const BSONObj& spec );
private:
- void _scoreRecurse(const Tools& tools,
- const BSONObj& obj,
- TermFrequencyMap* term_freqs ) const;
-
void _scoreString( const Tools& tools,
const StringData& raw,
TermFrequencyMap* term_freqs,