couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ian Mayo <>
Subject Cloaking calls to external API (ElasticSearch)
Date Wed, 25 Apr 2012 09:06:19 GMT
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

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:

Is this achievable?

Are there any better ways of doing this?


View raw message