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 an Expression.
Since:
5.9.4
  • Field Details

    • schemaManager

      protected final SchemaManager schemaManager
    • idKey

      protected final String idKey
    • 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 Details

  • Method Details

    • walk

      public void walk()
      Overrides:
      walk in class MongoDBAbstractQueryBuilder
    • 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 class MongoDBAbstractQueryBuilder
    • 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 class MongoDBAbstractQueryBuilder
    • walkNotEq

      public org.bson.Document walkNotEq(Operand lvalue, Operand rvalue)
      Overrides:
      walkNotEq in class MongoDBAbstractQueryBuilder
    • walkIn

      public org.bson.Document walkIn(Operand lvalue, Operand rvalue, boolean positive)
      Overrides:
      walkIn in class MongoDBAbstractQueryBuilder
    • 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 with a/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

      protected String getMongoDBPrefix(String prefix)
      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 class MongoDBAbstractQueryBuilder
    • 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 class MongoDBAbstractQueryBuilder
    • 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]}}]}