couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From CGS <cgsmcml...@gmail.com>
Subject Re: Cloaking calls to external API (ElasticSearch)
Date Wed, 25 Apr 2012 09:48:07 GMT
Hi Ian,

I don't suppose I understood well your problem, so, one question to get
your point: why do you want to use ES for searching through your CouchDB if
you want a direct search with CouchDB REST API?

If I understood well, you want to start a process (more precisely, ES in
this case) on the server-side using CouchDB, don't you?

Or I got it totally wrong...

CGS





On Wed, Apr 25, 2012 at 11:06 AM, Ian Mayo <ian@planetmayo.com> 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
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message