Discussion:
[mongodb-user] C# GridFS, custom index on metadata
Jens Christiansen
2018-06-15 20:58:58 UTC
Permalink
Hi

How do I in C# create an index on custom field in the metadata of GridFS?

I'm currently adding a custom object as metadata and I really like to add
an index to one of the attributes in the object.

Regards,
Jens Christiansen
--
You received this message because you are subscribed to the Google Groups "mongodb-user"
group.

For other MongoDB technical support options, see: https://docs.mongodb.com/manual/support/
---
You received this message because you are subscribed to the Google Groups "mongodb-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mongodb-user+***@googlegroups.com.
To post to this group, send email to mongodb-***@googlegroups.com.
Visit this group at https://groups.google.com/group/mongodb-user.
To view this discussion on the web visit https://groups.google.com/d/msgid/mongodb-user/c07619a3-5731-4645-81ef-f54e25ae387f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
'Wan Bachtiar' via mongodb-user
2018-06-21 06:35:44 UTC
Permalink
How do I in C# create an index on custom field in the metadata of GridFS?

Hi Jens,

I’m assuming you’re referring to the files.metadata
<https://docs.mongodb.com/manual/core/gridfs/#files.metadata>.
GridFS <https://docs.mongodb.com/manual/core/gridfs/#gridfs> stores files
in two collections, chunks and files.
For the metadata fields in the files
<https://docs.mongodb.com/manual/core/gridfs/#gridfs-files-collection>, you
can just create an index as any other index.

For example, to add an index on a files metadata field called foo:

var collection = database.GetCollection<BsonDocument>("fs.files");
var keys = Builders<BsonDocument>.IndexKeys.Ascending("metadata.foo");

Regards,
Wan.
​
--
You received this message because you are subscribed to the Google Groups "mongodb-user"
group.

For other MongoDB technical support options, see: https://docs.mongodb.com/manual/support/
---
You received this message because you are subscribed to the Google Groups "mongodb-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mongodb-user+***@googlegroups.com.
To post to this group, send email to mongodb-***@googlegroups.com.
Visit this group at https://groups.google.com/group/mongodb-user.
To view this discussion on the web visit https://groups.google.com/d/msgid/mongodb-user/bfaacb2e-eea4-464d-b506-a591438d1aad%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Loading...