This project is not being actively maintained. If you are interested in helping to maintain this project, take a look at the open issues on GitHub and submit pull requests.

CouchDB Lucene Queries

If you are using the CouchDB-Lucene integration you can make use of Lucene querying with Doctrine CouchDB ODM.

See the docs of CouchDB Lucene how you can create a design document with views for Lucene.

You can use the design-doc API of Doctrine, for example:


use Doctrine\ODM\CouchDB\View\DesignDocument;

class LuceneQueryDesignDoc implements DesignDocument
    public function getData()
        return array(
            "fulltext" => array(
                "by_name" => array(
                    "index" => "function(doc) {
                        var ret = new Document();
                        ret.add(doc.type, {field: \"type\"});
                        return ret;

You can use the CouchDB Client to create the design document for this lucene view.

When you have created a CouchDB Lucene view you can query it with Doctrine using the DocumentManager#createLuceneQuery($designDocName, $viewName) method. A lucene query instance extends AbstractQuery like the Doctrine CouchDB Map-Reduce queries.

An example showing all the functionalities of a lucene query looks like:

$query = $dm->createLuceneQuery("designDocName", "viewName");
$result = $query->setQuery("+bar -foo")

The result works as explained in the View and Map-Reduce Queries section.