You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@couchdb.apache.org by afshin afzali <a....@gmail.com> on 2010/07/01 23:29:40 UTC

Newbie Question about View's Startkey Match (Forked)

Sorry, But I  don't know why list rejects my post!!!

Ok, assume we have three object keys which emited by a view;

{  "FirstName" : "Afshin", "LastName" : "Afzali" }
{  "FirstName" : "Omid", "LastName" : "Afzali" }
{  "FirstName" : "Ashkan", "LastName" : "Afzali" }

I want to retreive all docs which have LastName == "Afzali"
-- afshin

Re: Newbie Question about View's Startkey Match (Forked)

Posted by J Chris Anderson <jc...@gmail.com>.
sounds like you want CouchDB Lucene for fulltext queries:

http://github.com/rnewson/couchdb-lucene


On Jul 1, 2010, at 3:00 PM, afshin afzali wrote:

> This is ok, But in real world my problem is more complicated. In my project,
> there is a CONTACT document that will contains all information that somebody
> may has: Name(First, Middle, Last, Nick), Phone(Home, Work, Cell..)
> Addresses(Home, Work, ...) Emails, IM(s), ... So we should provide a search
> page which contains all search items that user may use to retrieve desired
> contact. I was thinking that I could emit all of searchable information of
> CONTACT document, then when I query my view just insert those data which
> provided by user and use some don't care notaion for others :(
> 
> -- afshin
> 
> On Fri, Jul 2, 2010 at 2:15 AM, Robert Newson <ro...@gmail.com>wrote:
> 
>> You'll need to emit the last name first so that the items with the
>> same last name sort together.
>> 
>> function(doc) {
>> emit([doc.lastname, doc.firstname], null);
>> }
>> 
>> and then query with ?startkey=["Afzali"]&endkey=["Afzali",{}]
>> 
>> more simply;
>> 
>> function(doc) {
>> emit(doc.lastname, null);
>> }
>> 
>> and then query with ?key="Afzali"
>> 
>> B.
>> 
>> 
>> On Thu, Jul 1, 2010 at 10:29 PM, afshin afzali <a....@gmail.com>
>> wrote:
>>> Sorry, But I  don't know why list rejects my post!!!
>>> 
>>> Ok, assume we have three object keys which emited by a view;
>>> 
>>> {  "FirstName" : "Afshin", "LastName" : "Afzali" }
>>> {  "FirstName" : "Omid", "LastName" : "Afzali" }
>>> {  "FirstName" : "Ashkan", "LastName" : "Afzali" }
>>> 
>>> I want to retreive all docs which have LastName == "Afzali"
>>> -- afshin
>>> 
>> 


Re: Newbie Question about View's Startkey Match (Forked)

Posted by afshin afzali <a....@gmail.com>.
This is ok, But in real world my problem is more complicated. In my project,
there is a CONTACT document that will contains all information that somebody
may has: Name(First, Middle, Last, Nick), Phone(Home, Work, Cell..)
Addresses(Home, Work, ...) Emails, IM(s), ... So we should provide a search
page which contains all search items that user may use to retrieve desired
contact. I was thinking that I could emit all of searchable information of
CONTACT document, then when I query my view just insert those data which
provided by user and use some don't care notaion for others :(

-- afshin

On Fri, Jul 2, 2010 at 2:15 AM, Robert Newson <ro...@gmail.com>wrote:

> You'll need to emit the last name first so that the items with the
> same last name sort together.
>
> function(doc) {
>  emit([doc.lastname, doc.firstname], null);
> }
>
> and then query with ?startkey=["Afzali"]&endkey=["Afzali",{}]
>
> more simply;
>
> function(doc) {
>  emit(doc.lastname, null);
> }
>
> and then query with ?key="Afzali"
>
> B.
>
>
> On Thu, Jul 1, 2010 at 10:29 PM, afshin afzali <a....@gmail.com>
> wrote:
> > Sorry, But I  don't know why list rejects my post!!!
> >
> > Ok, assume we have three object keys which emited by a view;
> >
> > {  "FirstName" : "Afshin", "LastName" : "Afzali" }
> > {  "FirstName" : "Omid", "LastName" : "Afzali" }
> > {  "FirstName" : "Ashkan", "LastName" : "Afzali" }
> >
> > I want to retreive all docs which have LastName == "Afzali"
> > -- afshin
> >
>

Re: Newbie Question about View's Startkey Match (Forked)

Posted by Robert Newson <ro...@gmail.com>.
You'll need to emit the last name first so that the items with the
same last name sort together.

function(doc) {
  emit([doc.lastname, doc.firstname], null);
}

and then query with ?startkey=["Afzali"]&endkey=["Afzali",{}]

more simply;

function(doc) {
  emit(doc.lastname, null);
}

and then query with ?key="Afzali"

B.


On Thu, Jul 1, 2010 at 10:29 PM, afshin afzali <a....@gmail.com> wrote:
> Sorry, But I  don't know why list rejects my post!!!
>
> Ok, assume we have three object keys which emited by a view;
>
> {  "FirstName" : "Afshin", "LastName" : "Afzali" }
> {  "FirstName" : "Omid", "LastName" : "Afzali" }
> {  "FirstName" : "Ashkan", "LastName" : "Afzali" }
>
> I want to retreive all docs which have LastName == "Afzali"
> -- afshin
>