Return-Path: X-Original-To: apmail-couchdb-user-archive@www.apache.org Delivered-To: apmail-couchdb-user-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 788CB9C5F for ; Wed, 25 Apr 2012 13:21:02 +0000 (UTC) Received: (qmail 50777 invoked by uid 500); 25 Apr 2012 13:21:00 -0000 Delivered-To: apmail-couchdb-user-archive@couchdb.apache.org Received: (qmail 50743 invoked by uid 500); 25 Apr 2012 13:21:00 -0000 Mailing-List: contact user-help@couchdb.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@couchdb.apache.org Delivered-To: mailing list user@couchdb.apache.org Received: (qmail 50734 invoked by uid 99); 25 Apr 2012 13:21:00 -0000 Received: from minotaur.apache.org (HELO minotaur.apache.org) (140.211.11.9) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 25 Apr 2012 13:21:00 +0000 Received: from localhost (HELO mail-iy0-f180.google.com) (127.0.0.1) (smtp-auth username rnewson, mechanism plain) by minotaur.apache.org (qpsmtpd/0.29) with ESMTP; Wed, 25 Apr 2012 13:21:00 +0000 Received: by iage36 with SMTP id e36so120302iag.11 for ; Wed, 25 Apr 2012 06:20:59 -0700 (PDT) MIME-Version: 1.0 Received: by 10.50.222.162 with SMTP id qn2mr2419997igc.65.1335360059819; Wed, 25 Apr 2012 06:20:59 -0700 (PDT) Received: by 10.42.240.135 with HTTP; Wed, 25 Apr 2012 06:20:59 -0700 (PDT) In-Reply-To: References: Date: Wed, 25 Apr 2012 14:20:59 +0100 Message-ID: Subject: Re: Cloaking calls to external API (ElasticSearch) From: Robert Newson To: user@couchdb.apache.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Hi Ian, I found your question perfectly clear (though I may have been the only one). The way to achieve this is as I described, write a new external handler and add it to couchdb. For comparison, couchdb-lucene uses a Python script (https://github.com/rnewson/couchdb-lucene/blob/master/couchd= b-external-hook.py) for this purpose. When you POST to couchdb at hostname:port/dbname/_fti the body is passed to the script, and you can then do whatever you like. In my case, and yours, this is to transform the input into a query to an external HTTP service. In my case, couchdb-lucene. In yours, ElasticSearch. B. On 25 April 2012 14:14, Ian Mayo wrote: > It appears my question could have been more clear. =A0Sorry about that - > I'm unfamiliar with some of the language/terms used in CouchDb/REST. > > I have two servers. =A0One running a CouchDb database. =A0The other runs > an ElasticServer [ES] database, which automatically indexed the > CouchDb documents. > > ES is queried by collating a JSON search object, and passing that in a > GET to the search URI. > > I'd like to tidy this architecture in two ways: > 1) =A0Make it appear I'm just using the CouchDb database. > 2) =A0Allow search query to be expressed purely in a URI > > So, I'd like to introduce a capability in CouchDb to handle (redirect) > the search call - solving 1). =A0I'd also like this capability to be > able to parse the URI parameters and produce a JSON search object, as > shown in the initial message. > > I have a suspicion that I may be able to provide this capability in an > _attachment - though I welcome any feedback/correction/clarification. > > cheers, > Ian