couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Robert Samuel Newson <rnew...@apache.org>
Subject Re: Matching docs which values ending with a specific string
Date Wed, 12 Feb 2014 23:20:57 GMT
Tito,

You’re missing the point. You can’t select by the second element of the array for the
same reason you can’t select by the second half of your original string. :)

Benoit’s suggestion to do both is good, as long as you don’t care to know whether you’ve
found a town or a city. If you do, then;

emit(["town_city", doc.town, doc.city], null);
emit(["city_town", doc.city, doc.town], null);

(or two separate views).

B.

On 12 Feb 2014, at 23:17, Benoit Chesneau <bchesneau@gmail.com> wrote:

> On Wed, Feb 12, 2014 at 11:35 PM, Tito Ciuro <tciuro@mac.com> wrote:
>> Hello,
>> 
>> I have a database with documents with the following format:
>> 
>> {
>>    "_id" : "12345",
>>    "location" : <some_city>.<some town>
>> }
>> 
> 
> you can emit[<some_city>,<some town>] *and* [<some town>, <some_city>]
> so you can query either by city or town.
> 
> 
> - benoit


Mime
View raw message