liveBook · Manning

Db.collection.getSearchIndexes()

As explained in MongoDB 8.0 in Action, Third Edition

db.collection.getSearchIndex() is a MongoDB collection method that retrieves the configuration of one or more Atlas Search indexes.

db.collection.getSearchIndexes() retrieves Atlas Search or Vector Search index configurations from a MongoDB collection. Use it to inspect index definitions and verify that an index is ready and queryable. section 11.6 section 14.5.3

Use the method in two ways:

  • Pass an index name to retrieve that index's configuration. section 11.6
  • Omit the argument to retrieve configurations for every index in the collection. section 11.6
  • Check returned status and queryable fields before relying on a newly created index. section 13.5.2 section 14.5.3

Verify a vector search index

Switch to the target database and run db.mongodb.getSearchIndexes(). The result can show the default vectorSearch index, READY status, queryable: true, the embedding path, 1,536 dimensions, and cosine similarity. section 14.5.3

db.embedded_movies.getSearchIndexes()
[
  {
    id: '66afe77ea85a4d1064106885',
    name: 'default',
    type: 'search',
    status: 'READY',
    queryable: true,
    latestVersion: 0,
    latestDefinition: {
      mappings: {
        dynamic: true,
        fields: {
          plot_embedding: {
            type: 'knnVector',
            dimensions: 1536,
            similarity: 'euclidean'
          }
        }
      }
    }
  }
]

Inspect a complete returned configuration, including its identifier, type, readiness, queryability, and knnVector definition. section 13.5.2

The method is useful after createSearchIndex() or Atlas CLI index creation, especially in local development and test workflows. It reports configuration; creating, updating, and dropping indexes use separate operations. section 13.6 section 11.6

How MongoDB 8.0 in Action, Third Edition covers it

How deep it goes
Defines named and collection-wide retrieval, then demonstrates returned metadata; it stops short of internal index management.
Examples
Uses full-text and vector indexes, including LocalSearchIndex and a 1,536-dimensional embedding index.
What it assumes
Assumes a MongoDB collection and an existing or recently created Atlas Search or Vector Search index.
What you can do after
Operate index verification with mongosh by reading configuration, status, queryability, and field definitions.
How it connects
Connects index inspection with Atlas Search, Vector Search, createSearchIndex(), updateSearchIndex(), dropSearchIndex(), and Atlas CLI.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of MongoDB 8.0 in Action, Third Edition. The section links point to the parts of the book it draws on.