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 7087E91F8 for ; Wed, 25 Apr 2012 12:52:34 +0000 (UTC) Received: (qmail 55446 invoked by uid 500); 25 Apr 2012 12:52:32 -0000 Delivered-To: apmail-couchdb-user-archive@couchdb.apache.org Received: (qmail 55402 invoked by uid 500); 25 Apr 2012 12:52:32 -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 55384 invoked by uid 99); 25 Apr 2012 12:52:32 -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 12:52:32 +0000 Received: from localhost (HELO mail-gy0-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 12:52:31 +0000 Received: by ghbz12 with SMTP id z12so51302ghb.11 for ; Wed, 25 Apr 2012 05:52:31 -0700 (PDT) MIME-Version: 1.0 Received: by 10.50.6.166 with SMTP id c6mr2281881iga.65.1335358350818; Wed, 25 Apr 2012 05:52:30 -0700 (PDT) Received: by 10.42.240.135 with HTTP; Wed, 25 Apr 2012 05:52:30 -0700 (PDT) In-Reply-To: <3ED5F360-D31F-4EE8-ABCC-D0815CF9DC6D@dionne-associates.com> References: <3ED5F360-D31F-4EE8-ABCC-D0815CF9DC6D@dionne-associates.com> Date: Wed, 25 Apr 2012 13:52:30 +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, 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 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 intuitiv= e. >> >> As we all know, however, CouchDb doesn't have great search support >> (free-text, boolean queries, etc). =A0So, I'm using ElasticSearch [ES] >> to provide this capability. =A0It'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. =A0Plus, 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: >> >> =3D=3D=3D=3D=3D=3D >> { >> =A0 =A0 =A0 =A0"size" : 60, >> =A0 =A0 =A0 =A0"query" : >> =A0 =A0 =A0 =A0{ >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0"bool" : >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0{ >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0"should" : [ >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0{ "term" = : { "forename" : "Jack" } } , >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0{ "term" = : { "forename" : "Jill" } } >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0], >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0"minimum_number_should_match" : 1 >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0} >> =A0 =A0 =A0 =A0} >> } >> =3D=3D=3D=3D=3D=3D >> >> 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=3Dforename: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=3Dforename= :Jack+Jill >> >> Is this achievable? >> >> Are there any better ways of doing this? >> >> Cheers, >> Ian >