Child pages
  • Evidence Text Search Setup
Skip to end of metadata
Go to start of metadata

 

Setup text index on all text based fields ($**):

db.evidence.ensureIndex(
    {"$**": "text"},
    {"name": "TextIndex"}
)

Query index for Evidences:

db.evidence.find({$text: { $search: "AKT1" }})

 

db.evidence.find({$text: { $search: "10097102" }})

 

db.evidence.find({$text: { $search: "PubMed" }})

 

db.evidence.find({$text: { $search: 'Not Available' -PubMed " }})   # find all evidences with the phrase Not available (case insensitive) that do not have PubMed in them.  


Limitations:

  • Search is case insensitive
  • Only one search index on a collection - can't setup specific field searches
  • Only one text search per query with some limited boolean/phrase/negation functionality

Search capabilities: http://docs.mongodb.org/manual/reference/operator/query/text/

Useful blog entry on Text Indexing:  https://blog.compose.io/mongodb-and-full-text-search-my-first-week-with-mongodb-2-4-development-release/

 

  • No labels