-
Notifications
You must be signed in to change notification settings - Fork 14
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
DOCSP-39685: Indexes landing page #75
Conversation
✅ Deploy Preview for docs-java-rs ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
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 + some small things!
source/indexes.txt
Outdated
|
||
collection.createIndex(Indexes.ascending("stars", "name")) | ||
.subscribe(new PrintToStringSubscriber<String>()); | ||
.. include:: /includes/usage-examples/sample-app-intro.rst |
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.
Step 4 from this included file says
Copy the following code and paste it into a new Java file named
WriteOperations.java
.
WriteOperations.java
is wrong for this PR, given that the class name in index-code-examples.java
is IndexOperations
.
MongoCollection<Document> collection = database.getCollection("movies"); | ||
|
||
// start-single-field | ||
collection.createIndex(Indexes.ascending("<field name>")); |
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.
Similarly to other pages for the reactive driver, like #69, this one should both have the same note about Project Reactor Library, and actually execute the operations is demonstrates. collection.createIndex(Indexes.ascending("<field name>"))
simply creates an object of the Publisher<String>
type. It does not create an index. One way to execute the operation is, for example:
Mono<String> result = collection.createIndex(Indexes.ascending("<field name>"));
Mono.from(result).block();
This comment applies to many other examples in this PR.
import com.mongodb.reactivestreams.client.*; | ||
import org.bson.Document; | ||
import org.bson.conversions.Bson; | ||
import reactor.core.publisher.Flux; |
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.
The imports here must be the same as in index-code-examples.java
, otherwise some code from index-code-examples.java
may not compile when copied in IndexOperations
.
CreateCollectionOptions createCollectionOptions= new CreateCollectionOptions() | ||
.clusteredIndexOptions(clusteredIndexOptions); | ||
|
||
MongoCollection<Document> collection = database.createCollection("<collection name>", |
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.
The collection
variable is declared in sample-index-application.java
on line 32, which means, the another collection
variable cannot be declared here.
MongoCollection<Document> collection = database.createCollection("<collection name>", | |
MongoCollection<Document> clusteredCollection = database.createCollection("<collection name>", |
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.
I can make this change for clarity's sake.
With that said, the individual examples in this code are intended to be separately copy-pasted by readers into the sample application provided at the start of the page (as opposed to running the entire sample-index-application.java
file on its own). There may be some variable reuse in implementing your other feedback, FYI.
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.
It's not for clarity. If you actually try to copy this example into the sample application, you'll discover that it does not compile for the reason I specified.
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.
Ah, I get it now! Appreciate the callouts!!
CreateCollectionOptions createCollectionOptions= new CreateCollectionOptions() | ||
.clusteredIndexOptions(clusteredIndexOptions); | ||
|
||
MongoCollection<Document> collection = database.createCollection("<collection name>", |
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.
database.createCollection
does not return MongoCollection<Document>
, it returns Publisher<Void>
. Could you please try each example, to make sure it compiles and runs successfully?
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.
One nit and one question
MongoCollection<Document> collection = database.getCollection("movies"); | ||
|
||
// start-single-field | ||
Publisher<String> result = collection.createIndex(Indexes.ascending("<field name>")); |
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.
Nit: result
is a misleading variable name as nothing has happened, these methods return a Publisher
and nothing happens until its subscribed to.
Recommend renaming all variables called result.
@@ -0,0 +1,11 @@ | |||
You can use the following sample application to test the code examples on this |
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.
This seems out of place, given other examples in the documentation don't provide such information. Generally, they seem to provide a block about the examples using Project reactor.
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.
I can add the extra info about using Project reactor to be more in line with the Read/Write landing pages.
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!
Pull Request Info
PR Reviewing Guidelines
JIRA - https://jira.mongodb.org/browse/DOCSP-39685
Staging - https://preview-mongodbmcmorisi.gatsbyjs.io/java-rs/DOCSP-39685-indexes/indexes/
Self-Review Checklist