You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@couchdb.apache.org by Pavan Kumar <tv...@gmail.com> on 2010/05/28 11:33:31 UTC

_changes/Filter detecting new documents

Hi ,

 using _changes API with filters, can i detect if the document is a newly
Created one or Modified one ? What i understand now is that for both of the
scenarios ( new documents added or existing document changed ) _changes API
will give a reply back.

 Is there a way to differentiate ?

Thanks,
Pavan

Re: _changes/Filter detecting new documents

Posted by J Chris Anderson <jc...@gmail.com>.
On May 28, 2010, at 11:28 PM, Sebastian Cohnen wrote:

> I'm not sure that this is working properly, when replication is involved. As far as I understood the _changes API it is only guaranteed to get the latest change to a document, not every single one. When replication is involved it is possible to miss a newly created document and only see an updated one (first part of the MVCC token >1), when it's being replicated to the node where the _changes feed is consumed from.
> 

that's true. if you have a few edits rapidly in a row, you might not see a doc in the changes feed until a later revision (even on a single node), as the _changes feed only shows the latest edit of a doc.

if you want to process a doc the first time it shows up at a node, you can use filtered changes to only see docs that don't have doc.markedAsProcessed == true, and then process those docs, and add the corresponding field.

Chris


> 
> On 29.05.2010, at 05:04, Pavan Kumar wrote:
> 
>> Thanks guys, will go the rev id split way as of now.
>> 
>> On Fri, May 28, 2010 at 10:42 PM, J Chris Anderson <jc...@gmail.com> wrote:
>> 
>>> 
>>> On May 28, 2010, at 8:54 AM, Zachary Zolton wrote:
>>> 
>>>> I was just thinking on this problem the other day....
>>>> 
>>>> The only thing I can think of is looking at the _rev of the document.
>>>> Unfortunately, the format of the _rev has changed in the past, and it
>>>> may change in the future. So I think we're supposed to treat it as an
>>>> opaque token.
>>>> 
>>>> Hmm... Hopefully someone else has a better solution.
>>>> 
>>> 
>>> I've started to write code that depends on the fact that the rev is
>>> structured like "3-abcdefabcedef" (eg I've got some code that splits by "-",
>>> etc).
>>> 
>>> So you could look for docs with a rev that starts with 1. I'm not sure how
>>> good an idea it is to do that...
>>> 
>>>> --Zach
>>>> 
>>>> On Fri, May 28, 2010 at 4:33 AM, Pavan Kumar <tv...@gmail.com> wrote:
>>>>> Hi ,
>>>>> 
>>>>> using _changes API with filters, can i detect if the document is a
>>> newly
>>>>> Created one or Modified one ? What i understand now is that for both of
>>> the
>>>>> scenarios ( new documents added or existing document changed ) _changes
>>> API
>>>>> will give a reply back.
>>>>> 
>>>>> Is there a way to differentiate ?
>>>>> 
>>>>> Thanks,
>>>>> Pavan
>>>>> 
>>> 
>>> 
> 


Re: _changes/Filter detecting new documents

Posted by Sebastian Cohnen <se...@googlemail.com>.
I'm not sure that this is working properly, when replication is involved. As far as I understood the _changes API it is only guaranteed to get the latest change to a document, not every single one. When replication is involved it is possible to miss a newly created document and only see an updated one (first part of the MVCC token >1), when it's being replicated to the node where the _changes feed is consumed from.


On 29.05.2010, at 05:04, Pavan Kumar wrote:

> Thanks guys, will go the rev id split way as of now.
> 
> On Fri, May 28, 2010 at 10:42 PM, J Chris Anderson <jc...@gmail.com> wrote:
> 
>> 
>> On May 28, 2010, at 8:54 AM, Zachary Zolton wrote:
>> 
>>> I was just thinking on this problem the other day....
>>> 
>>> The only thing I can think of is looking at the _rev of the document.
>>> Unfortunately, the format of the _rev has changed in the past, and it
>>> may change in the future. So I think we're supposed to treat it as an
>>> opaque token.
>>> 
>>> Hmm... Hopefully someone else has a better solution.
>>> 
>> 
>> I've started to write code that depends on the fact that the rev is
>> structured like "3-abcdefabcedef" (eg I've got some code that splits by "-",
>> etc).
>> 
>> So you could look for docs with a rev that starts with 1. I'm not sure how
>> good an idea it is to do that...
>> 
>>> --Zach
>>> 
>>> On Fri, May 28, 2010 at 4:33 AM, Pavan Kumar <tv...@gmail.com> wrote:
>>>> Hi ,
>>>> 
>>>> using _changes API with filters, can i detect if the document is a
>> newly
>>>> Created one or Modified one ? What i understand now is that for both of
>> the
>>>> scenarios ( new documents added or existing document changed ) _changes
>> API
>>>> will give a reply back.
>>>> 
>>>> Is there a way to differentiate ?
>>>> 
>>>> Thanks,
>>>> Pavan
>>>> 
>> 
>> 


Re: _changes/Filter detecting new documents

Posted by Pavan Kumar <tv...@gmail.com>.
Thanks guys, will go the rev id split way as of now.

On Fri, May 28, 2010 at 10:42 PM, J Chris Anderson <jc...@gmail.com> wrote:

>
> On May 28, 2010, at 8:54 AM, Zachary Zolton wrote:
>
> > I was just thinking on this problem the other day....
> >
> > The only thing I can think of is looking at the _rev of the document.
> > Unfortunately, the format of the _rev has changed in the past, and it
> > may change in the future. So I think we're supposed to treat it as an
> > opaque token.
> >
> > Hmm... Hopefully someone else has a better solution.
> >
>
> I've started to write code that depends on the fact that the rev is
> structured like "3-abcdefabcedef" (eg I've got some code that splits by "-",
> etc).
>
> So you could look for docs with a rev that starts with 1. I'm not sure how
> good an idea it is to do that...
>
> > --Zach
> >
> > On Fri, May 28, 2010 at 4:33 AM, Pavan Kumar <tv...@gmail.com> wrote:
> >> Hi ,
> >>
> >>  using _changes API with filters, can i detect if the document is a
> newly
> >> Created one or Modified one ? What i understand now is that for both of
> the
> >> scenarios ( new documents added or existing document changed ) _changes
> API
> >> will give a reply back.
> >>
> >>  Is there a way to differentiate ?
> >>
> >> Thanks,
> >> Pavan
> >>
>
>

Re: _changes/Filter detecting new documents

Posted by J Chris Anderson <jc...@gmail.com>.
On May 28, 2010, at 8:54 AM, Zachary Zolton wrote:

> I was just thinking on this problem the other day....
> 
> The only thing I can think of is looking at the _rev of the document.
> Unfortunately, the format of the _rev has changed in the past, and it
> may change in the future. So I think we're supposed to treat it as an
> opaque token.
> 
> Hmm... Hopefully someone else has a better solution.
> 

I've started to write code that depends on the fact that the rev is structured like "3-abcdefabcedef" (eg I've got some code that splits by "-", etc).

So you could look for docs with a rev that starts with 1. I'm not sure how good an idea it is to do that...

> --Zach
> 
> On Fri, May 28, 2010 at 4:33 AM, Pavan Kumar <tv...@gmail.com> wrote:
>> Hi ,
>> 
>>  using _changes API with filters, can i detect if the document is a newly
>> Created one or Modified one ? What i understand now is that for both of the
>> scenarios ( new documents added or existing document changed ) _changes API
>> will give a reply back.
>> 
>>  Is there a way to differentiate ?
>> 
>> Thanks,
>> Pavan
>> 


Re: _changes/Filter detecting new documents

Posted by Zachary Zolton <za...@gmail.com>.
I was just thinking on this problem the other day....

The only thing I can think of is looking at the _rev of the document.
Unfortunately, the format of the _rev has changed in the past, and it
may change in the future. So I think we're supposed to treat it as an
opaque token.

Hmm... Hopefully someone else has a better solution.

--Zach

On Fri, May 28, 2010 at 4:33 AM, Pavan Kumar <tv...@gmail.com> wrote:
> Hi ,
>
>  using _changes API with filters, can i detect if the document is a newly
> Created one or Modified one ? What i understand now is that for both of the
> scenarios ( new documents added or existing document changed ) _changes API
> will give a reply back.
>
>  Is there a way to differentiate ?
>
> Thanks,
> Pavan
>