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
ConstructorsConstructorDescriptionCreates newTextQueryinlanguage.Creates newTextQueryusing thelocales language.
For a full list of supported languages see the mongdodb reference manual for Text Search Languages.TextQuery(TextCriteria criteria) Creates newTextQueryfor givenTextCriteria. -
Method Summary
Modifier and TypeMethodDescriptionorg.bson.DocumentGet the fieldname used for scoringorg.bson.DocumentAdd 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.booleanisSorted()Returns true if theQueryhas a sort parameter.static TextQueryqueryText(TextCriteria criteria) Creates newTextQuerysearching for givenTextCriteria.voidsetScoreFieldName(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 newTextQueryinlanguage.
For a full list of supported languages see the mongdodb reference manual for Text Search Languages.- Parameters:
wordsAndPhrases-language-- See Also:
-
TextQuery
Creates newTextQueryusing thelocales 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 newTextQueryfor givenTextCriteria.- Parameters:
criteria- must not be null.
-
-
Method Details
-
queryText
Creates newTextQuerysearching 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:
getFieldsObjectin classQuery- Returns:
- the field
Document.
-
getSortObject
public org.bson.Document getSortObject()- Overrides:
getSortObjectin classQuery- Returns:
- the sort
Document.
-
isSorted
public boolean isSorted()Description copied from class:QueryReturns true if theQueryhas a sort parameter.
-