-
Notifications
You must be signed in to change notification settings - Fork 26
DOCSP-32634: Add Indexes page #206
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work! A few suggestions and link fixes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall looking great. Biggest recommendation is to use the strongly-typed Builders<T>.IndexKeys
builder rather than specifying indexes as BsonDocument
or JSON strings.
Console.WriteLine("wildcard index"); | ||
|
||
// begin-wildcard-index | ||
collection.Indexes.CreateOne(Builders<Theater>.IndexKeys.Ascending("location.$**")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@JamesKovacs Wanted to specifically draw your attention here – is this the preferred way to implement an ascending wildcard index using the Builders model?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have a Wildcard
method on IndexKeys
.
coll.Indexes.CreateOne(
new CreateIndexModel<Theater>(Builders<Review>.IndexKeys.Wildcard(x => x.Location))
);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this case, would the x.Location
wildcard be defined in the Theater
Poco as something like this?
[BsonElement("location.$**")]
public string LocationGeo { get; set; }
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[BsonElement]
specifies the field name in the database and is unrelated to wildcard indexes. You would still specify this field as location.geo
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few more changes...
Console.WriteLine("wildcard index"); | ||
|
||
// begin-wildcard-index | ||
collection.Indexes.CreateOne(Builders<Theater>.IndexKeys.Ascending("location.$**")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have a Wildcard
method on IndexKeys
.
coll.Indexes.CreateOne(
new CreateIndexModel<Theater>(Builders<Review>.IndexKeys.Wildcard(x => x.Location))
);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
(cherry picked from commit d150844)
(cherry picked from commit d150844)
(cherry picked from commit d150844)
(cherry picked from commit d150844)
(cherry picked from commit d150844)
(cherry picked from commit d150844)
(cherry picked from commit d150844)
(cherry picked from commit d150844)
Pull Request Info
PR Reviewing Guidelines
JIRA - DOCSP-32634
Staging - https://preview-mongodbmcmorisi.gatsbyjs.io/csharp/DOCSP-32634-indexes/fundamentals/indexes/
Self-Review Checklist