Class TextQuery
java.lang.Object
org.springframework.data.mongodb.core.query.Query
org.springframework.data.mongodb.core.query.TextQuery
- All Implemented Interfaces:
ReadConcernAware
,ReadPreferenceAware
Query
implementation to be used to for performing full text searches.- Since:
- 1.6
- Author:
- Christoph Strobl, Mark Paluch
-
Constructor Summary
ConstructorDescriptionCreates newTextQuery
inlanguage
.Creates newTextQuery
using thelocale
s language.
For a full list of supported languages see the mongdodb reference manual for Text Search Languages.TextQuery
(TextCriteria criteria) Creates newTextQuery
for givenTextCriteria
. -
Method Summary
Modifier and TypeMethodDescriptionorg.bson.Document
Get the fieldname used for scoringorg.bson.Document
Add field score holding the documents textScore to the returned fields.includeScore
(String fieldname) Include text search document score in returned fields using the given fieldname.boolean
isSorted()
Returns true if theQuery
has a sort parameter.static TextQuery
queryText
(TextCriteria criteria) Creates newTextQuery
searching for givenTextCriteria
.void
setScoreFieldName
(String fieldName) Set the fieldname used for scoring.Add sorting by text score.Methods inherited from class org.springframework.data.mongodb.core.query.Query
addCriteria, allowDiskUse, allowSecondaryReads, collation, comment, cursorBatchSize, equals, exhaust, fields, getCollation, getCriteria, getHint, getKeyset, getLimit, getMeta, getQueryObject, getReadConcern, getReadPreference, getRestrictedTypes, getSkip, hashCode, hasKeyset, hasReadConcern, hasReadPreference, isLimited, isRestrictedTypeKey, limit, limit, maxTime, maxTimeMsec, noCursorTimeout, of, partialResults, query, querySettingsEquals, restrict, setMeta, skip, toString, with, with, with, with, with, withHint, withHint, withReadConcern, withReadPreference
-
Constructor Details
-
TextQuery
- Parameters:
wordsAndPhrases
-- See Also:
-
TextQuery
Creates newTextQuery
inlanguage
.
For a full list of supported languages see the mongdodb reference manual for Text Search Languages.- Parameters:
wordsAndPhrases
-language
-- See Also:
-
TextQuery
Creates newTextQuery
using thelocale
s language.
For a full list of supported languages see the mongdodb reference manual for Text Search Languages.- Parameters:
wordsAndPhrases
- must not be null.locale
- can be null.
-
TextQuery
Creates newTextQuery
for givenTextCriteria
.- Parameters:
criteria
- must not be null.
-
-
Method Details
-
queryText
Creates newTextQuery
searching for givenTextCriteria
.- Parameters:
criteria
- must not be null.- Returns:
- new instance of
TextQuery
.
-
sortByScore
Add sorting by text score. Will also add text score to returned fields.- Returns:
- this.
- See Also:
-
includeScore
Add field score holding the documents textScore to the returned fields.- Returns:
- this.
-
includeScore
Include text search document score in returned fields using the given fieldname.- Parameters:
fieldname
- must not be null.- Returns:
- this.
-
setScoreFieldName
Set the fieldname used for scoring.- Parameters:
fieldName
- must not be null.
-
getScoreFieldName
Get the fieldname used for scoring- Returns:
- never null.
-
getFieldsObject
public org.bson.Document getFieldsObject()- Overrides:
getFieldsObject
in classQuery
- Returns:
- the field
Document
.
-
getSortObject
public org.bson.Document getSortObject()- Overrides:
getSortObject
in classQuery
- Returns:
- the sort
Document
.
-
isSorted
public boolean isSorted()Description copied from class:Query
Returns true if theQuery
has a sort parameter.
-