Docs Menu

Simple Analyzer

The simple analyzer divides text into searchable terms wherever it finds a non-letter character, such as whitespace, punctuation, or one or more digits. It converts all terms to lower case.

The following example index definition specifies an index on the summary field using the simple analyzer:

{
"mappings": {
"fields": {
"summary": {
"type": "string",
"analyzer": "lucene.simple"
}
}
}
}

Consider a collection named cases with the following documents:

{ "_id": 1, "summary": "No action required at this time." }
{ "_id": 2, "summary": "Case set aside for future action." }
{ "_id": 3, "summary": "Frank's case is ready for planning." }

The following query uses the index on the summary field:

db.cases.aggregate([
{
$search: {
"text": {
"query": "frank",
"path": "summary"
}
}
}
])

The above query returns the following result:

{ "_id" : 3, "summary" : "Frank's case is ready for planning." }

The simple analyzer indexes Frank's case as [frank s case], so it matches on the search term frank.

Give Feedback
MongoDB logo
© 2021 MongoDB, Inc.

About

  • Careers
  • Legal Notices
  • Privacy Notices
  • Security Information
  • Trust Center
© 2021 MongoDB, Inc.