coll.Indexes + Atlas Search Index?

TLDR: The Atlas Search indexes don’t seem to show up on the list when checking all indexes on a collection via the C# driver.

I really did try to search(mongo help/google/etc) but either my search terms are terrible or I am just bad at searching…

Anyway, is there a way to determine if a Mongo Atlas Search(the fancy new text search) index exists on a table?

I am using:
C# Driver
Latest NuGet Version
I tried the standard Collection.Indexes.List() and it does not show up there even though it exists
I can 100% confirm it does indeed exist
Code to use it runs and works and I can verify it used the index. So the index is fine, I just can’t figure out via code if it exists.

Justification:
Not all tables or search terms have or are valid for my full text search. So one of my checks in code is a pretty basic “if table has Search index, use it, otherwise do a regex(or something else)”. I understand I should probably convert the regex to another Search Index or an added field, but there are a few reasons to not do this.

Hi @Mark_Mann,

To my knowledge the atlas search index won’t show up with the standard listIndexes command. I believe you can use the $listSearchIndexes stage in an aggregation pipeline to retrieve the Atlas Search indexes created on a particular collection instead.

An example of the aggregation stage for returning all atlas search indexes on a collection.

Hope this helps.

Regards,
Jason

1 Like

Additionally, we have added helper methods to aid working with Atlas search indexes (creation/management/search). They should be part of next release (version 2.21.0).
Reference: CSHARP-4660

2 Likes

Thank you both. Looks like I have a workaround for now and sometime next year some additional helper functions. Thank you.

2 Likes

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.