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:
1 <?php
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.name);
ret.add(doc.type, {field: \"type\"});
return ret;
}"
)
),
);
}
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
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:
The result works as explained in the View and Map-Reduce Queries section.