You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@couchdb.apache.org by Ayhan Kesenci <a....@googlemail.com> on 2015/03/04 18:56:25 UTC

Seachring specific Word in couchdb

Hey friends how should my map function looks like to find this document
 412918563004231700

doc.id="412918563004231700") doenst work :(


Thank you

Ayhan

Re: Seachring specific Word in couchdb

Posted by Peter Grman <pe...@gmail.com>.
Hi Ayhan, I didn't really understand if that's what you want to achieve,
but you have a semicolon after the if - condition, that's why emit is
called for every document and not just the one fitting the condition.

Also inside emit you should emit the document directly instead of a
true/false comparison with the id.

Regards,
Peter

On Wed, Mar 4, 2015 at 7:16 PM Ayhan Kesenci <a....@googlemail.com>
wrote:

> Okay this works but i get again more than  I want , but thank you, so i try
> this
> function (doc) { if (doc.id == '412918563004231700');
>  { emit(doc.id == '412918563004231700', null); }}
>
> so i get a true or false, than i let it sort by true, so i can identify the
> file that i need, thank you jonas :)
>
> 2015-03-04 19:08 GMT+01:00 Jonas Weber <ma...@jonasw.de>:
>
> > So sorry, I forgot an } at the end (I always do).
> >
> >
> > On 4 March 2015, Ayhan Kesenci <a....@googlemail.com> wrote:
> >
> > Get an Error Message, does not evaluate.
> >
> >
> > Ayhan
> >
> > 2015-03-04 18:59 GMT+01:00 Jonas Weber <ma...@jonasw.de>:
> >
> > Hi Ayhan,
> >
> > does function (doc) { if (doc.id == '412918563004231700') { emit(doc.id,
> > null); } work? Note that in order to see the document with this map, you
> > have to use ?include_docs=true.
> >
> > Maps are real functions, and what you have there is an assignment.
> >
> > Regards,
> > Jonas
> >
> >
> > On 4 March 2015, Ayhan Kesenci <a....@googlemail.com> wrote:
> >
> > Hey friends how should my map function looks like to find this document
> > 412918563004231700
> >
> > doc.id="412918563004231700") doenst work :(
> >
> >
> > Thank you
> >
> > Ayhan
> >
> >
> >
>

Re: Seachring specific Word in couchdb

Posted by Kiril Stankov <ki...@open-net.biz>.
As parameters to the query. Depends what you use to query CouchDB.
As an http request, it would look something like:
http://host:5984/{dbname}/_design/{design_doc}/_view/{view}?startkey='412918563004231700'&endkey='412918563004231700'&include_docs=true
If you use a wrapper, like nano for node.js, you can add the keys to the 
query
------------------------------------------------------------------------
*best regards,*
Kiril Stankov,

On 05-Mar-15 12:23 AM, Ayhan Kesenci wrote:
> where i put startkey and endkey andrew ??
>
> 2015-03-04 19:51 GMT+01:00 Andrew Koster <an...@samsung.com>:
>
>> There does not seem to be much difference between your method and Jonas's
>> solution. However, if all you need is to get the document with
>> include_docs, for the sake of optimality, you can just emit(null, null)
>> instead of doing that extra string comparison. Additionally, you can
>> emit(null, doc) and do away with ?include_docs=true.
>>
>> If you are really sure you will only ever need it with that specific ID,
>> then that solution will work, but in case you want to make it more general
>> (allow it to search for ANY document id, you can use the view:
>>
>> function(doc) { emit(doc.id, null); }
>>
>> and then query it with
>> ?startkey='412918563004231700'&endkey='412918563004231700'
>> Wrap this in a more user friendly page/function and you have a nice and
>> generic solution.
>>
>> Cheers,
>> Andrew
>>
>>
>>
>> -----Original Message-----
>> From: Ayhan Kesenci [mailto:a.kesenci89@googlemail.com]
>> Sent: 04 March 2015 15:15
>> To: user@couchdb.apache.org; mail@jonasw.de
>> Subject: Re: Seachring specific Word in couchdb
>>
>> Okay this works but i get again more than  I want , but thank you, so i
>> try this function (doc) { if (doc.id == '412918563004231700');  { emit(
>> doc.id == '412918563004231700', null); }}
>>
>> so i get a true or false, than i let it sort by true, so i can identify
>> the file that i need, thank you jonas :)
>>
>> 2015-03-04 19:08 GMT+01:00 Jonas Weber <ma...@jonasw.de>:
>>
>>> So sorry, I forgot an } at the end (I always do).
>>>
>>>
>>> On 4 March 2015, Ayhan Kesenci <a....@googlemail.com> wrote:
>>>
>>> Get an Error Message, does not evaluate.
>>>
>>>
>>> Ayhan
>>>
>>> 2015-03-04 18:59 GMT+01:00 Jonas Weber <ma...@jonasw.de>:
>>>
>>> Hi Ayhan,
>>>
>>> does function (doc) { if (doc.id == '412918563004231700') {
>>> emit(doc.id, null); } work? Note that in order to see the document
>>> with this map, you have to use ?include_docs=true.
>>>
>>> Maps are real functions, and what you have there is an assignment.
>>>
>>> Regards,
>>> Jonas
>>>
>>>
>>> On 4 March 2015, Ayhan Kesenci <a....@googlemail.com> wrote:
>>>
>>> Hey friends how should my map function looks like to find this
>>> document
>>> 412918563004231700
>>>
>>> doc.id="412918563004231700") doenst work :(
>>>
>>>
>>> Thank you
>>>
>>> Ayhan
>>>
>>>
>>>
>>


Re: Seachring specific Word in couchdb

Posted by Ayhan Kesenci <a....@googlemail.com>.
where i put startkey and endkey andrew ??

2015-03-04 19:51 GMT+01:00 Andrew Koster <an...@samsung.com>:

> There does not seem to be much difference between your method and Jonas's
> solution. However, if all you need is to get the document with
> include_docs, for the sake of optimality, you can just emit(null, null)
> instead of doing that extra string comparison. Additionally, you can
> emit(null, doc) and do away with ?include_docs=true.
>
> If you are really sure you will only ever need it with that specific ID,
> then that solution will work, but in case you want to make it more general
> (allow it to search for ANY document id, you can use the view:
>
> function(doc) { emit(doc.id, null); }
>
> and then query it with
> ?startkey='412918563004231700'&endkey='412918563004231700'
> Wrap this in a more user friendly page/function and you have a nice and
> generic solution.
>
> Cheers,
> Andrew
>
>
>
> -----Original Message-----
> From: Ayhan Kesenci [mailto:a.kesenci89@googlemail.com]
> Sent: 04 March 2015 15:15
> To: user@couchdb.apache.org; mail@jonasw.de
> Subject: Re: Seachring specific Word in couchdb
>
> Okay this works but i get again more than  I want , but thank you, so i
> try this function (doc) { if (doc.id == '412918563004231700');  { emit(
> doc.id == '412918563004231700', null); }}
>
> so i get a true or false, than i let it sort by true, so i can identify
> the file that i need, thank you jonas :)
>
> 2015-03-04 19:08 GMT+01:00 Jonas Weber <ma...@jonasw.de>:
>
> > So sorry, I forgot an } at the end (I always do).
> >
> >
> > On 4 March 2015, Ayhan Kesenci <a....@googlemail.com> wrote:
> >
> > Get an Error Message, does not evaluate.
> >
> >
> > Ayhan
> >
> > 2015-03-04 18:59 GMT+01:00 Jonas Weber <ma...@jonasw.de>:
> >
> > Hi Ayhan,
> >
> > does function (doc) { if (doc.id == '412918563004231700') {
> > emit(doc.id, null); } work? Note that in order to see the document
> > with this map, you have to use ?include_docs=true.
> >
> > Maps are real functions, and what you have there is an assignment.
> >
> > Regards,
> > Jonas
> >
> >
> > On 4 March 2015, Ayhan Kesenci <a....@googlemail.com> wrote:
> >
> > Hey friends how should my map function looks like to find this
> > document
> > 412918563004231700
> >
> > doc.id="412918563004231700") doenst work :(
> >
> >
> > Thank you
> >
> > Ayhan
> >
> >
> >
>
>

RE: Seachring specific Word in couchdb

Posted by Andrew Koster <an...@samsung.com>.
There does not seem to be much difference between your method and Jonas's solution. However, if all you need is to get the document with include_docs, for the sake of optimality, you can just emit(null, null) instead of doing that extra string comparison. Additionally, you can emit(null, doc) and do away with ?include_docs=true.

If you are really sure you will only ever need it with that specific ID, then that solution will work, but in case you want to make it more general (allow it to search for ANY document id, you can use the view: 

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

and then query it with ?startkey='412918563004231700'&endkey='412918563004231700'
Wrap this in a more user friendly page/function and you have a nice and generic solution.

Cheers,
Andrew



-----Original Message-----
From: Ayhan Kesenci [mailto:a.kesenci89@googlemail.com] 
Sent: 04 March 2015 15:15
To: user@couchdb.apache.org; mail@jonasw.de
Subject: Re: Seachring specific Word in couchdb

Okay this works but i get again more than  I want , but thank you, so i try this function (doc) { if (doc.id == '412918563004231700');  { emit(doc.id == '412918563004231700', null); }}

so i get a true or false, than i let it sort by true, so i can identify the file that i need, thank you jonas :)

2015-03-04 19:08 GMT+01:00 Jonas Weber <ma...@jonasw.de>:

> So sorry, I forgot an } at the end (I always do).
>
>
> On 4 March 2015, Ayhan Kesenci <a....@googlemail.com> wrote:
>
> Get an Error Message, does not evaluate.
>
>
> Ayhan
>
> 2015-03-04 18:59 GMT+01:00 Jonas Weber <ma...@jonasw.de>:
>
> Hi Ayhan,
>
> does function (doc) { if (doc.id == '412918563004231700') { 
> emit(doc.id, null); } work? Note that in order to see the document 
> with this map, you have to use ?include_docs=true.
>
> Maps are real functions, and what you have there is an assignment.
>
> Regards,
> Jonas
>
>
> On 4 March 2015, Ayhan Kesenci <a....@googlemail.com> wrote:
>
> Hey friends how should my map function looks like to find this 
> document
> 412918563004231700
>
> doc.id="412918563004231700") doenst work :(
>
>
> Thank you
>
> Ayhan
>
>
>


Re: Seachring specific Word in couchdb

Posted by Ayhan Kesenci <a....@googlemail.com>.
Okay this works but i get again more than  I want , but thank you, so i try
this
function (doc) { if (doc.id == '412918563004231700');
 { emit(doc.id == '412918563004231700', null); }}

so i get a true or false, than i let it sort by true, so i can identify the
file that i need, thank you jonas :)

2015-03-04 19:08 GMT+01:00 Jonas Weber <ma...@jonasw.de>:

> So sorry, I forgot an } at the end (I always do).
>
>
> On 4 March 2015, Ayhan Kesenci <a....@googlemail.com> wrote:
>
> Get an Error Message, does not evaluate.
>
>
> Ayhan
>
> 2015-03-04 18:59 GMT+01:00 Jonas Weber <ma...@jonasw.de>:
>
> Hi Ayhan,
>
> does function (doc) { if (doc.id == '412918563004231700') { emit(doc.id,
> null); } work? Note that in order to see the document with this map, you
> have to use ?include_docs=true.
>
> Maps are real functions, and what you have there is an assignment.
>
> Regards,
> Jonas
>
>
> On 4 March 2015, Ayhan Kesenci <a....@googlemail.com> wrote:
>
> Hey friends how should my map function looks like to find this document
> 412918563004231700
>
> doc.id="412918563004231700") doenst work :(
>
>
> Thank you
>
> Ayhan
>
>
>

Re: Seachring specific Word in couchdb

Posted by Jonas Weber <ma...@jonasw.de>.
So sorry, I forgot an } at the end (I always do).


On 4 March 2015, Ayhan Kesenci <a....@googlemail.com> wrote:
> Get an Error Message, does not evaluate.
> 
> 
> Ayhan
> 
> 2015-03-04 18:59 GMT+01:00 Jonas Weber <<m...@jonasw.de>>:
> 
> > Hi Ayhan,
> > 
> > does function (doc) { if (doc.id == '412918563004231700') { emit(doc.id,
> > null); } work? Note that in order to see the document with this map, you
> > have to use ?include_docs=true.
> > 
> > Maps are real functions, and what you have there is an assignment.
> > 
> > Regards,
> > Jonas
> > 
> > 
> > On 4 March 2015, Ayhan Kesenci <<a...@googlemail.com>> wrote:
> > 
> > Hey friends how should my map function looks like to find this document
> > 412918563004231700
> > 
> > doc.id="412918563004231700") doenst work :(
> > 
> > 
> > Thank you
> > 
> > Ayhan
> > 
> > 
> > 

Re: Seachring specific Word in couchdb

Posted by Ayhan Kesenci <a....@googlemail.com>.
Get an Error Message, does not evaluate.


Ayhan

2015-03-04 18:59 GMT+01:00 Jonas Weber <ma...@jonasw.de>:

> Hi Ayhan,
>
> does function (doc) { if (doc.id == '412918563004231700') { emit(doc.id,
> null); } work? Note that in order to see the document with this map, you
> have to use ?include_docs=true.
>
> Maps are real functions, and what you have there is an assignment.
>
> Regards,
> Jonas
>
>
> On 4 March 2015, Ayhan Kesenci <a....@googlemail.com> wrote:
>
> Hey friends how should my map function looks like to find this document
> 412918563004231700
>
> doc.id="412918563004231700") doenst work :(
>
>
> Thank you
>
> Ayhan
>
>

Re: Seachring specific Word in couchdb

Posted by Jonas Weber <ma...@jonasw.de>.
Hi Ayhan,

does function (doc) { if (doc.id == '412918563004231700') { emit(doc.id, null); } work? Note that in order to see the document with this map, you have to use ?include_docs=true.

Maps are real functions, and what you have there is an assignment.

Regards,
Jonas


On 4 March 2015, Ayhan Kesenci <a....@googlemail.com> wrote:
> Hey friends how should my map function looks like to find this document
> 412918563004231700
> 
> doc.id="412918563004231700") doenst work :(
> 
> 
> Thank you
> 
> Ayhan
>