incubator-couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Robert Newson <rnew...@apache.org>
Subject Re: Cloaking calls to external API (ElasticSearch)
Date Wed, 25 Apr 2012 12:52:30 GMT
Hi Ian,

You can certainly add your own entry points to CouchDB's REST API
using "externals". The original version of this is described here:
http://wiki.apache.org/couchdb/ExternalProcesses but I recommend the
much enhanced version described here:
http://davispj.com/2010/09/26/new-couchdb-externals-api.html

B.

On 25 April 2012 11:09, Bob Dionne <dionne@dionne-associates.com> wrote:
> You might want to look at couchdb-lucene[1], it's integrated with couchdb.
>
> [1] https://github.com/rnewson/couchdb-lucene
>
> On Apr 25, 2012, at 5:06 AM, Ian Mayo wrote:
>
>> Hi all,
>> I'm loving the native REST support in CouchDb - it's robust and intuitive.
>>
>> As we all know, however, CouchDb doesn't have great search support
>> (free-text, boolean queries, etc).  So, I'm using ElasticSearch [ES]
>> to provide this capability.  It's working really well - ES is robust,
>> fast, and very versatile.
>>
>> My problem is that I'd like to avoid having to disparate REST
>> architectures - running through different hosts.  Plus, ES only
>> provides limited search for URI-based searches - more advanced
>> searches require a JSON payload like this one to search for a forename
>> of Jack or Jill:
>>
>> ======
>> {
>>        "size" : 60,
>>        "query" :
>>        {
>>                "bool" :
>>                {
>>                        "should" : [
>>                                { "term" : { "forename" : "Jack" }
} ,
>>                                { "term" : { "forename" : "Jill" }
}
>>                    ],
>>                    "minimum_number_should_match" : 1
>>                }
>>        }
>> }
>> ======
>>
>> So, what I'd like to do is to introduce a capability into my CouchDb
>> where I express my search terms in the URI, then the custom code
>> produces a suitable JSON payload, and invisibly redirects the call to
>> my ElasticSearch server.
>>
>> So, my client would call
>> http://host/contactsdb/[something]/search?q=forename:Jack+Jill
>>
>> My custom JS code would then produce a payload like that above, and
>> then fire the query to the ES server.
>>
>> Thus, the API is all based on http://host/contactsdb, and my client
>> apps do not have to create ES payloads, or know of the presence of ES.
>>
>> I guess I could put a file into the _attachments folder to do this, so
>> it would be:
>> http://host/contactsdb/_design/api/_attachments/search.html?q=forename:Jack+Jill
>>
>> Is this achievable?
>>
>> Are there any better ways of doing this?
>>
>> Cheers,
>> Ian
>

Mime
View raw message