public class Text extends Object
text
command to query a collection with
a text index
.
The result of a text
command is a document that looks like the
following:
> db.collection.runCommand( { "text": "collection" , search: "coffee magic" } ) { "queryDebugString" : "coffe|magic||||||", "language" : "english", "results" : [ { "score" : 2.25, "obj" : { "_id" : ObjectId("51376ab8602c316554cfe248"), "content" : "Coffee is full of magical powers." } }, { "score" : 0.625, "obj" : { "_id" : ObjectId("51376a80602c316554cfe246"), "content" : "Now is the time to drink all of the coffee." } } ], "stats" : { "nscanned" : 3, "nscannedObjects" : 0, "n" : 2, "nfound" : 2, "timeMicros" : 97 }, "ok" : 1 }
The TextResult
class wraps a single entry from the results
array.
Modifier and Type | Class and Description |
---|---|
static class |
Text.Builder
Builder provides a builder for Text commands.
|
Modifier | Constructor and Description |
---|---|
protected |
Text(Text.Builder builder)
Creates a new Text.
|
Modifier and Type | Method and Description |
---|---|
static Text.Builder |
builder()
Creates a new builder for a
Text command. |
String |
getLanguage()
Returns the language to use when stemming the search terms.
|
int |
getLimit()
Returns the maximum number of document to return.
|
Document |
getQuery()
Returns the query document to limit the final results.
|
ReadPreference |
getReadPreference()
Returns the
ReadPreference specifying which servers may be used
to execute the Text command. |
Document |
getReturnFields()
Returns the fields to return from the query.
|
String |
getSearchTerm()
Returns the search terms.
|
protected Text(Text.Builder builder)
builder
- The builder containing the state of the text command.IllegalArgumentException
- On the search term not being set.public static Text.Builder builder()
Text
command.Text
command.public String getLanguage()
public int getLimit()
public Document getQuery()
public ReadPreference getReadPreference()
ReadPreference
specifying which servers may be used
to execute the Text
command.
If null
then the MongoCollection
instance's
ReadPreference
will be used.
MongoCollection.getReadPreference()
public Document getReturnFields()
public String getSearchTerm()
Copyright © 2011-2013 Allanbank Consulting, Inc.. All Rights Reserved.