Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP


add support for full text search ie. CONTAINS() #50

lsmith77 opened this Issue · 9 comments

3 participants

Lukas Kahwe Smith Luis Cordova Crypto Compress
Lukas Kahwe Smith

conceptually this should be similar to
i.e. using an inverted index ( where we would split all text by word, drop that into a table and use that as a pre filter to reduce the number of rows that are considered for the XPaths.

for specs of CONTAINS() see
its ok if initially we do not support the full "lucene" style query syntax

see also for the grammar of SQL2

also not sure .. but maybe this could help to get started

Lukas Kahwe Smith

a quick implementation using equality matching rather than full text searching with normal xpath just to show where the code will need to hook into:

diff --git a/src/Jackalope/Transport/DoctrineDBAL/Query/QOMWalker.php b/src/Jackalope/Transport/DoctrineDBAL/Query/QOMWalker.php
index 7f9ba8c..e34017a 100644
--- a/src/Jackalope/Transport/DoctrineDBAL/Query/QOMWalker.php
+++ b/src/Jackalope/Transport/DoctrineDBAL/Query/QOMWalker.php
@@ -173,6 +173,9 @@ class QOMWalker
         if ($constraint instanceof QOM\SameNodeInterface) {
             return $this->walkSameNodeConstraint($constraint);
+        if ($constraint instanceof QOM\FullTextSearchInterface) {
+            return $this->walkFullTextSearchConstraint($constraint);
+        }

         throw new InvalidQueryException("Constraint " . get_class($constraint) . " not yet supported.");
@@ -187,6 +190,15 @@ class QOMWalker

+     * @param \PHPCR\Query\QOM\FullTextSearchConstraint $constraint
+     * @return string
+     */
+    public function walkFullTextSearchConstraint(QOM\FullTextSearchInterface $constraint)
+    {
+        return $this->sqlXpathExtractValue($this->getTableAlias($constraint->getSelectorName()), $this->getTableAlias($constraint->getPropertyName())).' = '. $this->conn->quote($constraint->getFullTextSearchExpression());
+    }
+    /**
      * @param QOM\PropertyExistenceInterface $constraint
     public function walkPropertyExistanceConstraint(QOM\PropertyExistenceInterface $constraint)
Lukas Kahwe Smith

just some notes

[16:42] syncNode($uuid, $path, $parent, $type, $isNewNode, $props = array(), $propsData = array())
[16:42] copyNode($srcAbsPath, $dstAbsPath, $srcWorkspace = null)
[16:43] deleteNode($path)
[16:43] deleteProperty($path)
[16:43] in this methods i have to update index... am i missing something?
[16:43] yeah

Luis Cordova

what are those passages references? just curious

Crypto Compress

yes, in QOMWalker the index has to be looked up and in this Client methods the index should be changed

Lukas Kahwe Smith

@cordoval these are methods in the transport client that get called by jackalope core to write data to the given transports backend. as such these are the places were any additional index needs to be updated.

Lukas Kahwe Smith

@cryptocompress did you try if it works using the XPath contains() function?

Crypto Compress

sorry, had no time. will do it now.
as described here:

Crypto Compress

very early but functional xpath-full-text-search can be found here:

feedback desired :)

Lukas Kahwe Smith

ok implemented something ultra simple with LIKE '%foo%' here eaac413

Lukas Kahwe Smith lsmith77 closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.