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

lsmith77 opened this Issue Jul 21, 2012 · 9 comments


None yet

3 participants

Jackalope member

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

Jackalope member

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)
Jackalope member

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


what are those passages references? just curious


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

Jackalope member

@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.

Jackalope member

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


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


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

feedback desired :)

Jackalope member

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

@lsmith77 lsmith77 closed this Oct 22, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment