What is the difference between 'index' and 'search index'?

I don’t understand the difference between ‘index’ and ‘search index’ just by reading thru official document. In Atlas, when setting index for a collection, i do not understand in which case I should use ‘index’ or ‘search index’. Should i use ‘search index’ for full text search only?

For two example, in mycollection, there is a field called ‘a’ and ‘b’, which is an string type and number type, and the query below will be used.

db.mycollection.find({“a”:“xxxxx”})
db.mycollection.find({“b”:12345})

About “a” and “b” field, i want make each index.
Is it ‘index’ to create an ‘a’ field? Is it “search index”?
Is it ‘index’ to create an ‘b’ field? Is it “search index”?

Hi @Damon_Kim and welcome to the MongoDB community forum!!

The Indexes in MongoDB are used for efficient execution for the query by limiting the number of documents getting scanned for the inspect. They enable the server to do less unnecessary work to return the query.
The MongoDB Atlas also gives the functionality to create, view and drop indexes. You can refer to the documentation for further understanding on How to use indexes in Atlas.

Atlas Search, in contrast, leverages the power of Apache Lucene to enable full text search indexes for your data. It enables you to create full-text indexes that are not available natively in MongoDB server deployed locally on-prem. Notably, this feature requires the use of Atlas.

Are you referring to the same index in the above example? To read more on Create an Atlas Search Index, you can refer to the documentation.

Let us know if you have any further queries.

Best Regards
Aasawari

1 Like

normal "index"ing is made on the “whole” value of the field, thus you need to also use whole values when you search. this indexed search will get you pretty fast.

But an index will not be used if you try to have a search on partial values, such as regex. in this case, all documents in the collection will be scanned which will in turn take longer.

with search index, you give up a bit more data space, but get a partial value (full-text) search capability with the speed of indexing.

so, knowing numbers and booleans (others?) are already searched as a whole, it comes down mostly to strings, and then your question just becomes:

do you want a faster partial search on those particular fields of that collection?

PS: There is a limit of 3-5-10 on the total number of search indexes for M0-M2-M5 clusters. Unlimited for M10+

Thank you for your answer. I understand.