Class MongoDBRepositoryQueryBuilder
java.lang.Object
org.nuxeo.ecm.core.storage.mongodb.MongoDBAbstractQueryBuilder
org.nuxeo.ecm.core.storage.mongodb.MongoDBRepositoryQueryBuilder
Query builder for a MongoDB query of the repository from an
Expression
.- Since:
- 5.9.4
-
Nested Class Summary
Nested classes/interfaces inherited from class org.nuxeo.ecm.core.storage.mongodb.MongoDBAbstractQueryBuilder
MongoDBAbstractQueryBuilder.FieldInfo
-
Field Summary
Modifier and TypeFieldDescriptionboolean
protected final String
protected static final Pattern
protected org.bson.Document
protected final OrderByClause
protected final ExpressionEvaluator.PathResolver
protected org.bson.Document
protected final SchemaManager
protected final SelectClause
boolean
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
ConstructorDescriptionMongoDBRepositoryQueryBuilder
(MongoDBRepository repository, Expression expression, SelectClause selectClause, OrderByClause orderByClause, ExpressionEvaluator.PathResolver pathResolver, boolean fulltextSearchDisabled) -
Method Summary
Modifier and TypeMethodDescriptionstatic String
canonicalXPath
(String xpath) Canonicalizes a Nuxeo-xpath.getMixinDocumentTypes
(String mixin) static String
getMongoDBFulltextQuery
(String query) protected String
getMongoDBPrefix
(String prefix) Computes the MongoDB prefix from the DBS common prefix.org.bson.Document
org.bson.Document
boolean
protected boolean
protected boolean
isNeverPerInstanceMixin
(String mixin) protected MongoDBAbstractQueryBuilder.FieldInfo
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
org.bson.Document
walkExpression
(Expression expr) org.bson.Document
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
protected void
protected void
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 Details
-
schemaManager
-
idKey
-
documentTypes
-
selectClause
-
orderByClause
-
pathResolver
-
hasFulltext
public boolean hasFulltext -
sortOnFulltextScore
public boolean sortOnFulltextScore -
orderBy
protected org.bson.Document orderBy -
projection
protected org.bson.Document projection -
propertyKeys
-
NON_CANON_INDEX
-
-
Constructor Details
-
MongoDBRepositoryQueryBuilder
public MongoDBRepositoryQueryBuilder(MongoDBRepository repository, Expression expression, SelectClause selectClause, OrderByClause orderByClause, ExpressionEvaluator.PathResolver pathResolver, boolean fulltextSearchDisabled)
-
-
Method Details
-
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
- Overrides:
walkExpression
in classMongoDBAbstractQueryBuilder
-
walkEcmPath
-
walkAncestorId
-
walkEcmFulltext
-
walkIsTrashed
-
walkIsTrashed
-
getMongoDBFulltextQuery
-
translateFulltext
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
- Overrides:
walkEq
in classMongoDBAbstractQueryBuilder
-
walkNotEq
- Overrides:
walkNotEq
in classMongoDBAbstractQueryBuilder
-
walkIn
- Overrides:
walkIn
in classMongoDBAbstractQueryBuilder
-
walkStartsWith
-
walkStartsWithPath
-
walkStartsWithNonPath
-
canonicalXPath
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.
-
getMongoDBPrefix
Computes the MongoDB prefix from the DBS common prefix.foo/bar/*1 -> foo.bar. ecm:acp/*1/acl/*1 -> ecm:acp.acl.
Also strips prefix from unprefixed schemas.
files:files/*1 -> files.
- Overrides:
getMongoDBPrefix
in classMongoDBAbstractQueryBuilder
-
walkReference
Description copied from class:MongoDBAbstractQueryBuilder
Walks a reference, and returns field info about it.- Specified by:
walkReference
in classMongoDBAbstractQueryBuilder
-
parseACP
-
isMixinTypes
-
getMixinDocumentTypes
-
getDocumentTypes
-
isNeverPerInstanceMixin
-
walkMixinTypes
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]}}]}
-