incubator-couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dave Cottlehuber <d...@muse.net.nz>
Subject Re: Simulating SQL 'LIKE %' using Regular Expressions
Date Wed, 02 Jun 2010 08:01:04 GMT
On 2 June 2010 17:11,  <Steven.Prentice@nextgen.net> wrote:
> hmm...
>
> so would that mean that if I typed in ?key="Image/"
[...]
> similar to saying select mime-type * from some_table where mime-type LIKE
> %/%
>
> or am I reading this wrong

The example on the book
http://books.couchdb.org/relax/reference/views-for-sql-jockeys could
be construed as misleading. What you (& lots of others want) is to
allow the user to enter any search expression which in real time is
filtered against the DB, & a bunch of docs made available for further
actions.

My case is I have a bunch of devices (device1.abc.com, device2.def.org
etc etc) and want to enable somebody to search for "def" or "device1"
or any combo & then to return an array of those _ids to work with.

The issue here is that the index you use (the map) must be able to be
pre-calculated & stored in the B+tree for each doc. A regex search
can't by nature be pre-calculated if you can put anything you like in.
So you need somewhere (browser, middle tier, search engine like
lucence) to process that. The book example simply splits up using a
pre-existing regex & allows you to filter using that instead.

I've not tried this but had thought that for some use cases with short
keys and/or low doc volumes, you can pass the whole index from your
map fun "emit (doc._id, key)" style across to your web page via ajax
and do the filtering there. If you're going to re-use this field, and
it can be cached both proxy layer and in browser the initial hit of
several 10-100KB might be an acceptable trade-off to load the index
down.

Are there any other options?
A+
D

Mime
View raw message