You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@couchdb.apache.org by Hank Knight <hk...@gmail.com> on 2014/04/07 20:59:54 UTC
couchdb-lucene: search attachment only if document criteria met
I use this to find all documents where foo == zooph
function(doc) {
if(doc.foo=='zooph') {
emit(null, doc);
}
}
I use this (powered by couchdb-lucene) to find all documents with
attachments containing "hello":
{
"_id": "_design/find",
"fulltext": {
"html": {
"index": "function(doc) {var result = new
Document();for(var a in doc._attachments)
{result.attachment('default', a);}return result;}"
}
}
}
http://example.com/_fti/local/resources/_design/find/html?q=hello
How can these be combined? I only want results that contain "hello"
where foo equals zooph.
Re: couchdb-lucene: search attachment only if document criteria met
Posted by Robert Samuel Newson <rn...@apache.org>.
add ret.add(doc.foo, {"field":"foo"}); to your index function and do
?q=foo:zooph+AND+hello
B.
On 7 Apr 2014, at 19:59, Hank Knight <hk...@gmail.com> wrote:
> I use this to find all documents where foo == zooph
>
> function(doc) {
> if(doc.foo=='zooph') {
> emit(null, doc);
> }
> }
>
> I use this (powered by couchdb-lucene) to find all documents with
> attachments containing "hello":
>
> {
> "_id": "_design/find",
> "fulltext": {
> "html": {
> "index": "function(doc) {var result = new
> Document();for(var a in doc._attachments)
> {result.attachment('default', a);}return result;}"
> }
> }
> }
> http://example.com/_fti/local/resources/_design/find/html?q=hello
>
> How can these be combined? I only want results that contain "hello"
> where foo equals zooph.