Class MongoDBRepositoryQueryBuilder

    • Field Detail

      • idKey

        protected final String idKey
      • documentTypes

        protected List<String> documentTypes
      • hasFulltext

        public boolean hasFulltext
      • sortOnFulltextScore

        public boolean sortOnFulltextScore
      • orderBy

        protected org.bson.Document orderBy
      • projection

        protected org.bson.Document projection
      • NON_CANON_INDEX

        protected static final Pattern NON_CANON_INDEX
    • Method Detail

      • getOrderBy

        public org.bson.Document getOrderBy()
      • getProjection

        public org.bson.Document getProjection()
      • hasProjectionWildcard

        public boolean hasProjectionWildcard()
      • walkOrderBy

        protected void walkOrderBy()
      • walkProjection

        protected void walkProjection()
      • 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)
      • 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.
      • 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
      • 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]}}]}