Class MongoDBRepositoryQueryBuilder
- java.lang.Object
-
- org.nuxeo.ecm.core.storage.mongodb.MongoDBAbstractQueryBuilder
-
- org.nuxeo.ecm.core.storage.mongodb.MongoDBRepositoryQueryBuilder
-
public class MongoDBRepositoryQueryBuilder extends MongoDBAbstractQueryBuilder
Query builder for a MongoDB query of the repository from anExpression
.- Since:
- 5.9.4
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.nuxeo.ecm.core.storage.mongodb.MongoDBAbstractQueryBuilder
MongoDBAbstractQueryBuilder.FieldInfo
-
-
Field Summary
Fields Modifier and Type Field Description protected List<String>
documentTypes
boolean
hasFulltext
protected String
idKey
protected static Pattern
NON_CANON_INDEX
protected org.bson.Document
orderBy
protected OrderByClause
orderByClause
protected ExpressionEvaluator.PathResolver
pathResolver
protected org.bson.Document
projection
protected Map<String,String>
propertyKeys
protected SchemaManager
schemaManager
protected SelectClause
selectClause
boolean
sortOnFulltextScore
-
Fields inherited from class org.nuxeo.ecm.core.storage.mongodb.MongoDBAbstractQueryBuilder
converter, DATE_CAST, elemMatchPrefix, expression, LIKE_ANCHORED_PROP, likeAnchored, LONG_ONE, LONG_ZERO, MINUS_ONE, ONE, query, SLASH_WILDCARD_SLASH
-
-
Constructor Summary
Constructors Constructor Description MongoDBRepositoryQueryBuilder(MongoDBRepository repository, Expression expression, SelectClause selectClause, OrderByClause orderByClause, ExpressionEvaluator.PathResolver pathResolver, boolean fulltextSearchDisabled)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static String
canonicalXPath(String xpath)
Canonicalizes a Nuxeo-xpath.protected List<String>
getDocumentTypes()
protected Set<String>
getMixinDocumentTypes(String mixin)
static String
getMongoDBFulltextQuery(String query)
org.bson.Document
getOrderBy()
org.bson.Document
getProjection()
boolean
hasProjectionWildcard()
protected boolean
isMixinTypes(MongoDBAbstractQueryBuilder.FieldInfo fieldInfo)
protected boolean
isNeverPerInstanceMixin(String mixin)
protected MongoDBAbstractQueryBuilder.FieldInfo
parseACP(String prop, String[] parts)
protected static String
translateFulltext(FulltextQueryAnalyzer.FulltextQuery ft, boolean and)
Transforms the NXQL fulltext syntax into MongoDB syntax.protected static void
translateFulltext(FulltextQueryAnalyzer.FulltextQuery ft, List<String> buf, boolean and)
void
walk()
protected org.bson.Document
walkAncestorId(Operator op, Operand rvalue)
protected org.bson.Document
walkEcmFulltext(String name, Operator op, Operand rvalue)
protected org.bson.Document
walkEcmPath(Operator op, Operand rvalue)
org.bson.Document
walkEq(Operand lvalue, Operand rvalue)
org.bson.Document
walkExpression(Expression expr)
org.bson.Document
walkIn(Operand lvalue, Operand rvalue, boolean positive)
protected org.bson.Document
walkIsTrashed(Operator op, Operand rvalue)
protected org.bson.Document
walkIsTrashed(Reference ref, Operator op, Operand initialRvalue, Literal deletedRvalue)
org.bson.Document
walkMixinTypes(List<String> mixins, boolean include)
Matches the mixin types against a list of values.org.bson.Document
walkNotEq(Operand lvalue, Operand rvalue)
protected void
walkOrderBy()
protected void
walkProjection()
protected MongoDBAbstractQueryBuilder.FieldInfo
walkReference(String name)
Walks a reference, and returns field info about it.org.bson.Document
walkStartsWith(Operand lvalue, Operand rvalue)
protected org.bson.Document
walkStartsWithNonPath(Operand lvalue, String path)
protected org.bson.Document
walkStartsWithPath(String path)
-
Methods inherited from class org.nuxeo.ecm.core.storage.mongodb.MongoDBAbstractQueryBuilder
checkDateLiteralForCast, checkDateLiteralForCast, getQuery, newDocumentWithField, pushDownNot, stripElemMatchPrefix, walkAndOr, walkAndOr, walkAndOrMultiExpression, walkBetween, walkBooleanLiteral, walkDateLiteral, walkDoubleLiteral, walkEq, walkFunction, walkGt, walkGtEq, walkIn, walkIntegerLiteral, walkIsNotNull, walkIsNull, walkLike, walkLiteral, walkLiteralList, walkLt, walkLtEq, walkNot, walkNotEq, walkOperand, walkOperandList, walkReference, walkReference, walkStringLiteral
-
-
-
-
Field Detail
-
schemaManager
protected final SchemaManager schemaManager
-
documentTypes
protected List<String> documentTypes
-
selectClause
protected final SelectClause selectClause
-
orderByClause
protected final OrderByClause orderByClause
-
pathResolver
protected final ExpressionEvaluator.PathResolver pathResolver
-
hasFulltext
public boolean hasFulltext
-
sortOnFulltextScore
public boolean sortOnFulltextScore
-
orderBy
protected org.bson.Document orderBy
-
projection
protected org.bson.Document projection
-
propertyKeys
protected Map<String,String> propertyKeys
-
NON_CANON_INDEX
protected static final Pattern NON_CANON_INDEX
-
-
Constructor Detail
-
MongoDBRepositoryQueryBuilder
public MongoDBRepositoryQueryBuilder(MongoDBRepository repository, Expression expression, SelectClause selectClause, OrderByClause orderByClause, ExpressionEvaluator.PathResolver pathResolver, boolean fulltextSearchDisabled)
-
-
Method Detail
-
walk
public void walk()
- Overrides:
walk
in classMongoDBAbstractQueryBuilder
-
getOrderBy
public org.bson.Document getOrderBy()
-
getProjection
public org.bson.Document getProjection()
-
hasProjectionWildcard
public boolean hasProjectionWildcard()
-
walkOrderBy
protected void walkOrderBy()
-
walkProjection
protected void walkProjection()
-
walkExpression
public org.bson.Document walkExpression(Expression expr)
- Overrides:
walkExpression
in classMongoDBAbstractQueryBuilder
-
walkEcmPath
protected org.bson.Document walkEcmPath(Operator op, Operand rvalue)
-
walkAncestorId
protected org.bson.Document walkAncestorId(Operator op, Operand rvalue)
-
walkEcmFulltext
protected org.bson.Document walkEcmFulltext(String name, Operator op, Operand rvalue)
-
walkIsTrashed
protected org.bson.Document walkIsTrashed(Operator op, Operand rvalue)
-
walkIsTrashed
protected org.bson.Document walkIsTrashed(Reference ref, Operator op, Operand initialRvalue, Literal deletedRvalue)
-
getMongoDBFulltextQuery
public static String getMongoDBFulltextQuery(String query)
-
translateFulltext
protected static String translateFulltext(FulltextQueryAnalyzer.FulltextQuery ft, boolean and)
Transforms the NXQL fulltext syntax into MongoDB syntax.The MongoDB fulltext query syntax is badly documented, but is actually the following:
- a term is a word,
- a phrase is a set of spaced-separated words enclosed in double quotes,
- negation is done by prepending a -,
- the query is a space-separated set of terms, negated terms, phrases, or negated phrases.
- all the words of non-negated phrases are also added to the terms.
The matching algorithm is (excluding stemming and stop words):
- filter out documents with the negative terms, the negative phrases, or missing the phrases,
- then if any term is present in the document then it's a match.
-
translateFulltext
protected static void translateFulltext(FulltextQueryAnalyzer.FulltextQuery ft, List<String> buf, boolean and)
-
walkEq
public org.bson.Document walkEq(Operand lvalue, Operand rvalue)
- Overrides:
walkEq
in classMongoDBAbstractQueryBuilder
-
walkNotEq
public org.bson.Document walkNotEq(Operand lvalue, Operand rvalue)
- Overrides:
walkNotEq
in classMongoDBAbstractQueryBuilder
-
walkIn
public org.bson.Document walkIn(Operand lvalue, Operand rvalue, boolean positive)
- Overrides:
walkIn
in classMongoDBAbstractQueryBuilder
-
walkStartsWith
public org.bson.Document walkStartsWith(Operand lvalue, Operand rvalue)
-
walkStartsWithPath
protected org.bson.Document walkStartsWithPath(String path)
-
walkStartsWithNonPath
protected org.bson.Document walkStartsWithNonPath(Operand lvalue, String path)
-
canonicalXPath
public static String canonicalXPath(String xpath)
Canonicalizes a Nuxeo-xpath.Replaces
a/foo[123]/b
witha/123/b
A star or a star followed by digits can be used instead of just the digits as well.
- Parameters:
xpath
- the xpath- Returns:
- the canonicalized xpath.
-
walkReference
protected MongoDBAbstractQueryBuilder.FieldInfo walkReference(String name)
Description copied from class:MongoDBAbstractQueryBuilder
Walks a reference, and returns field info about it.- Specified by:
walkReference
in classMongoDBAbstractQueryBuilder
-
parseACP
protected MongoDBAbstractQueryBuilder.FieldInfo parseACP(String prop, String[] parts)
-
isMixinTypes
protected boolean isMixinTypes(MongoDBAbstractQueryBuilder.FieldInfo fieldInfo)
-
getMixinDocumentTypes
protected Set<String> getMixinDocumentTypes(String mixin)
-
getDocumentTypes
protected List<String> getDocumentTypes()
-
isNeverPerInstanceMixin
protected boolean isNeverPerInstanceMixin(String mixin)
-
walkMixinTypes
public org.bson.Document walkMixinTypes(List<String> mixins, boolean include)
Matches the mixin types against a list of values.Used for:
- ecm:mixinTypes = 'Foo'
- ecm:mixinTypes != 'Foo'
- ecm:mixinTypes IN ('Foo', 'Bar')
- ecm:mixinTypes NOT IN ('Foo', 'Bar')
ecm:mixinTypes IN ('Foo', 'Bar')
{ "$or" : [ { "ecm:primaryType" : { "$in" : [ ... types with Foo or Bar ...]}} , { "ecm:mixinTypes" : { "$in" : [ "Foo" , "Bar]}}]}
ecm:mixinTypes NOT IN ('Foo', 'Bar')
{ "$and" : [ { "ecm:primaryType" : { "$in" : [ ... types without Foo nor Bar ...]}} , { "ecm:mixinTypes" : { "$nin" : [ "Foo" , "Bar]}}]}
-
-