Articles → MONGODB → Combined Text Index In Mongodb

Combined Text Index In Mongodb






Purpose





Syntax


db.collection.createIndex(
  {
    field1: "text",
    field2: "text",
    // Add additional fields here if needed
  }
)



Example




Picture showing the sample document collection




db.Employee.createIndex(
  {
    name: "text",
    country: "text"
  }
)



Output


Picture showing the output of combined text index in mongodb



Posted By  -  Karan Gupta
 
Posted On  -  Friday, May 10, 2024

Query/Feedback


Your Email Id
 
Subject
 
Query/FeedbackCharacters remaining 250