Is there any working cypher query to get status updates of friends (for
below model)? (similar to newsfeed in facebook)?
I am using latest SDN and 1.8GA.
In Neo4j documentation, it was given for traversal, am unable to convert it
into cypher query.
If there is any working example code that would be really great.
> Is there any working cypher query to get status updates of friends (for
> below model)? (similar to newsfeed in facebook)?
> I am using latest SDN and 1.8GA.
> In Neo4j documentation, it was given for traversal, am unable to convert
> it into cypher query.
> If there is any working example code that would be really great.
Thanks for the prompt response Wes.
NEXT relationship must also be included, as next.status might be the latest
one compared to s.status. struggling here to write a one...
And Lets say, i limit to 20 updates now. Next time when user wants next
list, i need to get next 20updates, by this time, there might be 10 new
updates, due to this i will get 10old updates(which was already retrieved
in first query).
Is this something that i need to handle after retrieving data?
On Wed, Oct 10, 2012 at 9:36 AM, Wes Freeman <freeman....@gmail.com> wrote:
> Something like? (replace 1 with node id of person)
> start n=node(1)
> match n-[:friend]->f-[:status]->s
> return s
> order by s.date;
> Wes
> On Tue, Oct 9, 2012 at 11:48 PM, Abdul Azeez Shaik <
> azeeztechni...@gmail.com> wrote:
>> Hi,
>> Is there any working cypher query to get status updates of friends (for
>> below model)? (similar to newsfeed in facebook)?
>> I am using latest SDN and 1.8GA.
>> In Neo4j documentation, it was given for traversal, am unable to convert
>> it into cypher query.
>> If there is any working example code that would be really great.
> wrote:
> Thanks for the prompt response Wes.
> NEXT relationship must also be included, as next.status might be the
> latest one compared to s.status. struggling here to write a one...
> And Lets say, i limit to 20 updates now. Next time when user wants next
> list, i need to get next 20updates, by this time, there might be 10 new
> updates, due to this i will get 10old updates(which was already retrieved
> in first query).
> Is this something that i need to handle after retrieving data?
> Thanks,
> Abdul
> On Wed, Oct 10, 2012 at 9:36 AM, Wes Freeman <freeman....@gmail.com>wrote:
>> Something like? (replace 1 with node id of person)
>> start n=node(1)
>> match n-[:friend]->f-[:status]->s
>> return s
>> order by s.date;
>> Wes
>> On Tue, Oct 9, 2012 at 11:48 PM, Abdul Azeez Shaik <
>> azeeztechni...@gmail.com> wrote:
>>> Hi,
>>> Is there any working cypher query to get status updates of friends (for
>>> below model)? (similar to newsfeed in facebook)?
>>> I am using latest SDN and 1.8GA.
>>> In Neo4j documentation, it was given for traversal, am unable to convert
>>> it into cypher query.
>>> If there is any working example code that would be really great.
I tried same query with optional relationship in first subquery, first
subquery works fine.
However, second sub-query fails due to null in second query.
Can we avoid creating second relationship in oldsu is null?
Here is the updated query,
@Query( "START n=node:search(username={0}) MATCH n-[r?:STATUS]->oldsu
DELETE r " +
> However, how do i need to take care of is "su" doesn't exist, in that case
> second sub-query would not get executed.
> Kindly help me.
> Thanks,
> Abdul
> On Wed, Oct 10, 2012 at 9:48 AM, Abdul Azeez Shaik <
> azeeztechni...@gmail.com> wrote:
>> Thanks for the prompt response Wes.
>> NEXT relationship must also be included, as next.status might be the
>> latest one compared to s.status. struggling here to write a one...
>> And Lets say, i limit to 20 updates now. Next time when user wants next
>> list, i need to get next 20updates, by this time, there might be 10 new
>> updates, due to this i will get 10old updates(which was already retrieved
>> in first query).
>> Is this something that i need to handle after retrieving data?
>> Thanks,
>> Abdul
>> On Wed, Oct 10, 2012 at 9:36 AM, Wes Freeman <freeman....@gmail.com>wrote:
>>> Something like? (replace 1 with node id of person)
>>> start n=node(1)
>>> match n-[:friend]->f-[:status]->s
>>> return s
>>> order by s.date;
>>> Wes
>>> On Tue, Oct 9, 2012 at 11:48 PM, Abdul Azeez Shaik <
>>> azeeztechni...@gmail.com> wrote:
>>>> Hi,
>>>> Is there any working cypher query to get status updates of friends (for
>>>> below model)? (similar to newsfeed in facebook)?
>>>> I am using latest SDN and 1.8GA.
>>>> In Neo4j documentation, it was given for traversal, am unable to
>>>> convert it into cypher query.
>>>> If there is any working example code that would be really great.
Ok, got the first part, got confused unnecessarily.
start n=node(1)
match n-[:friend]->f-[:status]->s-[:next*0..]->su
return su
order by su.date desc;
Thanks for providing me initial help Wes.
Any help on the second part,
Lets say, i limit to 20 updates now. Next time when user wants next list, i
need to get next 20updates, by this time, there might be 10 new updates,
due to this i will get 10old updates(which was already retrieved in first
query).
Is this something that i need to handle after retrieving data?
On Wed, Oct 10, 2012 at 9:48 AM, Abdul Azeez Shaik <azeeztechni...@gmail.com
> wrote:
> Thanks for the prompt response Wes.
> NEXT relationship must also be included, as next.status might be the
> latest one compared to s.status. struggling here to write a one...
> And Lets say, i limit to 20 updates now. Next time when user wants next
> list, i need to get next 20updates, by this time, there might be 10 new
> updates, due to this i will get 10old updates(which was already retrieved
> in first query).
> Is this something that i need to handle after retrieving data?
> Thanks,
> Abdul
> On Wed, Oct 10, 2012 at 9:36 AM, Wes Freeman <freeman....@gmail.com>wrote:
>> Something like? (replace 1 with node id of person)
>> start n=node(1)
>> match n-[:friend]->f-[:status]->s
>> return s
>> order by s.date;
>> Wes
>> On Tue, Oct 9, 2012 at 11:48 PM, Abdul Azeez Shaik <
>> azeeztechni...@gmail.com> wrote:
>>> Hi,
>>> Is there any working cypher query to get status updates of friends (for
>>> below model)? (similar to newsfeed in facebook)?
>>> I am using latest SDN and 1.8GA.
>>> In Neo4j documentation, it was given for traversal, am unable to convert
>>> it into cypher query.
>>> If there is any working example code that would be really great.
> wrote:
> Ok, got the first part, got confused unnecessarily.
> start n=node(1)
> match n-[:friend]->f-[:status]->s-[:next*0..]->su
> return su
> order by su.date desc;
> Thanks for providing me initial help Wes.
> Any help on the second part,
> Lets say, i limit to 20 updates now. Next time when user wants next list,
> i need to get next 20updates, by this time, there might be 10 new updates,
> due to this i will get 10old updates(which was already retrieved in first
> query).
> Is this something that i need to handle after retrieving data?
> On Wed, Oct 10, 2012 at 9:48 AM, Abdul Azeez Shaik <
> azeeztechni...@gmail.com> wrote:
>> Thanks for the prompt response Wes.
>> NEXT relationship must also be included, as next.status might be the
>> latest one compared to s.status. struggling here to write a one...
>> And Lets say, i limit to 20 updates now. Next time when user wants next
>> list, i need to get next 20updates, by this time, there might be 10 new
>> updates, due to this i will get 10old updates(which was already retrieved
>> in first query).
>> Is this something that i need to handle after retrieving data?
>> Thanks,
>> Abdul
>> On Wed, Oct 10, 2012 at 9:36 AM, Wes Freeman <freeman....@gmail.com>wrote:
>>> Something like? (replace 1 with node id of person)
>>> start n=node(1)
>>> match n-[:friend]->f-[:status]->s
>>> return s
>>> order by s.date;
>>> Wes
>>> On Tue, Oct 9, 2012 at 11:48 PM, Abdul Azeez Shaik <
>>> azeeztechni...@gmail.com> wrote:
>>>> Hi,
>>>> Is there any working cypher query to get status updates of friends (for
>>>> below model)? (similar to newsfeed in facebook)?
>>>> I am using latest SDN and 1.8GA.
>>>> In Neo4j documentation, it was given for traversal, am unable to
>>>> convert it into cypher query.
>>>> If there is any working example code that would be really great.
In between first call and second call if there are 10 more status updates,
then it returns 10new and 10old(which are already return in first call) in
second call.
I am thinking to save posted data from first call and add this condition to
second call so that query doesn't consider new status updates.
Please let me know if this can be implemented in some other way.
On Wed, Oct 10, 2012 at 12:04 PM, Wes Freeman <freeman....@gmail.com> wrote:
> You can do:
> start n=node(1)
> match n-[:friend]->f-[:status]->s-[:next*0..]->su
> return su
> order by su.date desc
> skip 20
> limit 20;
> To skip the first 20, and get 20 more status updates. Then you can keep
> incrementing skip as you get more.
> Wes
> On Wed, Oct 10, 2012 at 2:14 AM, Abdul Azeez Shaik <
> azeeztechni...@gmail.com> wrote:
>> Ok, got the first part, got confused unnecessarily.
>> start n=node(1)
>> match n-[:friend]->f-[:status]->s-[:next*0..]->su
>> return su
>> order by su.date desc;
>> Thanks for providing me initial help Wes.
>> Any help on the second part,
>> Lets say, i limit to 20 updates now. Next time when user wants next list,
>> i need to get next 20updates, by this time, there might be 10 new updates,
>> due to this i will get 10old updates(which was already retrieved in first
>> query).
>> Is this something that i need to handle after retrieving data?
>> On Wed, Oct 10, 2012 at 9:48 AM, Abdul Azeez Shaik <
>> azeeztechni...@gmail.com> wrote:
>>> Thanks for the prompt response Wes.
>>> NEXT relationship must also be included, as next.status might be the
>>> latest one compared to s.status. struggling here to write a one...
>>> And Lets say, i limit to 20 updates now. Next time when user wants next
>>> list, i need to get next 20updates, by this time, there might be 10 new
>>> updates, due to this i will get 10old updates(which was already retrieved
>>> in first query).
>>> Is this something that i need to handle after retrieving data?
>>> Thanks,
>>> Abdul
>>> On Wed, Oct 10, 2012 at 9:36 AM, Wes Freeman <freeman....@gmail.com>wrote:
>>>> Something like? (replace 1 with node id of person)
>>>> start n=node(1)
>>>> match n-[:friend]->f-[:status]->s
>>>> return s
>>>> order by s.date;
>>>> Wes
>>>> On Tue, Oct 9, 2012 at 11:48 PM, Abdul Azeez Shaik <
>>>> azeeztechni...@gmail.com> wrote:
>>>>> Hi,
>>>>> Is there any working cypher query to get status updates of friends
>>>>> (for below model)? (similar to newsfeed in facebook)?
>>>>> I am using latest SDN and 1.8GA.
>>>>> In Neo4j documentation, it was given for traversal, am unable to
>>>>> convert it into cypher query.
>>>>> If there is any working example code that would be really great.
Are status updates linked together via next? Maybe you should just be
querying based on the oldest status update already returned, and then
following that path. For the new status updates, that should be a different
query (I think).
On Wed, Oct 10, 2012 at 2:50 AM, Abdul Azeez Shaik <azeeztechni...@gmail.com
> In between first call and second call if there are 10 more status updates,
> then it returns 10new and 10old(which are already return in first call) in
> second call.
> I am thinking to save posted data from first call and add this condition
> to second call so that query doesn't consider new status updates.
> Please let me know if this can be implemented in some other way.
> Thanks,
> Abdul
> On Wed, Oct 10, 2012 at 12:04 PM, Wes Freeman <freeman....@gmail.com>wrote:
>> You can do:
>> start n=node(1)
>> match n-[:friend]->f-[:status]->s-[:next*0..]->su
>> return su
>> order by su.date desc
>> skip 20
>> limit 20;
>> To skip the first 20, and get 20 more status updates. Then you can keep
>> incrementing skip as you get more.
>> Wes
>> On Wed, Oct 10, 2012 at 2:14 AM, Abdul Azeez Shaik <
>> azeeztechni...@gmail.com> wrote:
>>> Ok, got the first part, got confused unnecessarily.
>>> start n=node(1)
>>> match n-[:friend]->f-[:status]->s-[:next*0..]->su
>>> return su
>>> order by su.date desc;
>>> Thanks for providing me initial help Wes.
>>> Any help on the second part,
>>> Lets say, i limit to 20 updates now. Next time when user wants next
>>> list, i need to get next 20updates, by this time, there might be 10 new
>>> updates, due to this i will get 10old updates(which was already retrieved
>>> in first query).
>>> Is this something that i need to handle after retrieving data?
>>> On Wed, Oct 10, 2012 at 9:48 AM, Abdul Azeez Shaik <
>>> azeeztechni...@gmail.com> wrote:
>>>> Thanks for the prompt response Wes.
>>>> NEXT relationship must also be included, as next.status might be the
>>>> latest one compared to s.status. struggling here to write a one...
>>>> And Lets say, i limit to 20 updates now. Next time when user wants next
>>>> list, i need to get next 20updates, by this time, there might be 10 new
>>>> updates, due to this i will get 10old updates(which was already retrieved
>>>> in first query).
>>>> Is this something that i need to handle after retrieving data?
>>>> Thanks,
>>>> Abdul
>>>> On Wed, Oct 10, 2012 at 9:36 AM, Wes Freeman <freeman....@gmail.com>wrote:
>>>>> Something like? (replace 1 with node id of person)
>>>>> start n=node(1)
>>>>> match n-[:friend]->f-[:status]->s
>>>>> return s
>>>>> order by s.date;
>>>>> Wes
>>>>> On Tue, Oct 9, 2012 at 11:48 PM, Abdul Azeez Shaik <
>>>>> azeeztechni...@gmail.com> wrote:
>>>>>> Hi,
>>>>>> Is there any working cypher query to get status updates of friends
>>>>>> (for below model)? (similar to newsfeed in facebook)?
>>>>>> I am using latest SDN and 1.8GA.
>>>>>> In Neo4j documentation, it was given for traversal, am unable to
>>>>>> convert it into cypher query.
>>>>>> If there is any working example code that would be really great.
Thats a nice idea. It would make query too very simple.
Thanks for the help Wes.
Any idea on the other query which i posted on same thread?
I tried same query with optional relationship in first subquery, first
subquery works fine.
However, second sub-query fails due to null in second query.
Can we avoid creating second relationship in oldsu is null?
Here is the updated query,
@Query( "START n=node:search(username={0}) MATCH n-[r?:STATUS]->oldsu
DELETE r " +
On Wed, Oct 10, 2012 at 12:36 PM, Wes Freeman <freeman....@gmail.com> wrote:
> Are status updates linked together via next? Maybe you should just be
> querying based on the oldest status update already returned, and then
> following that path. For the new status updates, that should be a different
> query (I think).
> On Wed, Oct 10, 2012 at 2:50 AM, Abdul Azeez Shaik <
> azeeztechni...@gmail.com> wrote:
>> Hi Wes,
>> In between first call and second call if there are 10 more status
>> updates, then it returns 10new and 10old(which are already return in first
>> call) in second call.
>> I am thinking to save posted data from first call and add this condition
>> to second call so that query doesn't consider new status updates.
>> Please let me know if this can be implemented in some other way.
>> Thanks,
>> Abdul
>> On Wed, Oct 10, 2012 at 12:04 PM, Wes Freeman <freeman....@gmail.com>wrote:
>>> You can do:
>>> start n=node(1)
>>> match n-[:friend]->f-[:status]->s-[:next*0..]->su
>>> return su
>>> order by su.date desc
>>> skip 20
>>> limit 20;
>>> To skip the first 20, and get 20 more status updates. Then you can keep
>>> incrementing skip as you get more.
>>> Wes
>>> On Wed, Oct 10, 2012 at 2:14 AM, Abdul Azeez Shaik <
>>> azeeztechni...@gmail.com> wrote:
>>>> Ok, got the first part, got confused unnecessarily.
>>>> start n=node(1)
>>>> match n-[:friend]->f-[:status]->s-[:next*0..]->su
>>>> return su
>>>> order by su.date desc;
>>>> Thanks for providing me initial help Wes.
>>>> Any help on the second part,
>>>> Lets say, i limit to 20 updates now. Next time when user wants next
>>>> list, i need to get next 20updates, by this time, there might be 10 new
>>>> updates, due to this i will get 10old updates(which was already retrieved
>>>> in first query).
>>>> Is this something that i need to handle after retrieving data?
>>>> On Wed, Oct 10, 2012 at 9:48 AM, Abdul Azeez Shaik <
>>>> azeeztechni...@gmail.com> wrote:
>>>>> Thanks for the prompt response Wes.
>>>>> NEXT relationship must also be included, as next.status might be the
>>>>> latest one compared to s.status. struggling here to write a one...
>>>>> And Lets say, i limit to 20 updates now. Next time when user wants
>>>>> next list, i need to get next 20updates, by this time, there might be 10
>>>>> new updates, due to this i will get 10old updates(which was already
>>>>> retrieved in first query).
>>>>> Is this something that i need to handle after retrieving data?
>>>>> Thanks,
>>>>> Abdul
>>>>> On Wed, Oct 10, 2012 at 9:36 AM, Wes Freeman <freeman....@gmail.com>wrote:
>>>>>> Something like? (replace 1 with node id of person)
>>>>>> start n=node(1)
>>>>>> match n-[:friend]->f-[:status]->s
>>>>>> return s
>>>>>> order by s.date;
>>>>>> Wes
>>>>>> On Tue, Oct 9, 2012 at 11:48 PM, Abdul Azeez Shaik <
>>>>>> azeeztechni...@gmail.com> wrote:
>>>>>>> Hi,
>>>>>>> Is there any working cypher query to get status updates of friends
>>>>>>> (for below model)? (similar to newsfeed in facebook)?
>>>>>>> I am using latest SDN and 1.8GA.
>>>>>>> In Neo4j documentation, it was given for traversal, am unable to
>>>>>>> convert it into cypher query.
>>>>>>> If there is any working example code that would be really great.
> wrote:
> Thats a nice idea. It would make query too very simple.
> Thanks for the help Wes.
> Any idea on the other query which i posted on same thread?
> I tried same query with optional relationship in first subquery, first
> subquery works fine.
> However, second sub-query fails due to null in second query.
> Can we avoid creating second relationship in oldsu is null?
> Here is the updated query,
> @Query( "START n=node:search(username={0}) MATCH n-[r?:STATUS]->oldsu
> DELETE r " +
> On Wed, Oct 10, 2012 at 12:36 PM, Wes Freeman <freeman....@gmail.com>wrote:
>> Are status updates linked together via next? Maybe you should just be
>> querying based on the oldest status update already returned, and then
>> following that path. For the new status updates, that should be a different
>> query (I think).
>> On Wed, Oct 10, 2012 at 2:50 AM, Abdul Azeez Shaik <
>> azeeztechni...@gmail.com> wrote:
>>> Hi Wes,
>>> In between first call and second call if there are 10 more status
>>> updates, then it returns 10new and 10old(which are already return in first
>>> call) in second call.
>>> I am thinking to save posted data from first call and add this condition
>>> to second call so that query doesn't consider new status updates.
>>> Please let me know if this can be implemented in some other way.
>>> Thanks,
>>> Abdul
>>> On Wed, Oct 10, 2012 at 12:04 PM, Wes Freeman <freeman....@gmail.com>wrote:
>>>> You can do:
>>>> start n=node(1)
>>>> match n-[:friend]->f-[:status]->s-[:next*0..]->su
>>>> return su
>>>> order by su.date desc
>>>> skip 20
>>>> limit 20;
>>>> To skip the first 20, and get 20 more status updates. Then you can keep
>>>> incrementing skip as you get more.
>>>> Wes
>>>> On Wed, Oct 10, 2012 at 2:14 AM, Abdul Azeez Shaik <
>>>> azeeztechni...@gmail.com> wrote:
>>>>> Ok, got the first part, got confused unnecessarily.
>>>>> start n=node(1)
>>>>> match n-[:friend]->f-[:status]->s-[:next*0..]->su
>>>>> return su
>>>>> order by su.date desc;
>>>>> Thanks for providing me initial help Wes.
>>>>> Any help on the second part,
>>>>> Lets say, i limit to 20 updates now. Next time when user wants next
>>>>> list, i need to get next 20updates, by this time, there might be 10 new
>>>>> updates, due to this i will get 10old updates(which was already retrieved
>>>>> in first query).
>>>>> Is this something that i need to handle after retrieving data?
>>>>> On Wed, Oct 10, 2012 at 9:48 AM, Abdul Azeez Shaik <
>>>>> azeeztechni...@gmail.com> wrote:
>>>>>> Thanks for the prompt response Wes.
>>>>>> NEXT relationship must also be included, as next.status might be the
>>>>>> latest one compared to s.status. struggling here to write a one...
>>>>>> And Lets say, i limit to 20 updates now. Next time when user wants
>>>>>> next list, i need to get next 20updates, by this time, there might be 10
>>>>>> new updates, due to this i will get 10old updates(which was already
>>>>>> retrieved in first query).
>>>>>> Is this something that i need to handle after retrieving data?
>>>>>> Thanks,
>>>>>> Abdul
>>>>>> On Wed, Oct 10, 2012 at 9:36 AM, Wes Freeman <freeman....@gmail.com>wrote:
>>>>>>> Something like? (replace 1 with node id of person)
>>>>>>> start n=node(1)
>>>>>>> match n-[:friend]->f-[:status]->s
>>>>>>> return s
>>>>>>> order by s.date;
>>>>>>> Wes
>>>>>>> On Tue, Oct 9, 2012 at 11:48 PM, Abdul Azeez Shaik <
>>>>>>> azeeztechni...@gmail.com> wrote:
>>>>>>>> Hi,
>>>>>>>> Is there any working cypher query to get status updates of friends
>>>>>>>> (for below model)? (similar to newsfeed in facebook)?
>>>>>>>> I am using latest SDN and 1.8GA.
>>>>>>>> In Neo4j documentation, it was given for traversal, am unable to
>>>>>>>> convert it into cypher query.
>>>>>>>> If there is any working example code that would be really great.
On Wed, Oct 10, 2012 at 1:49 PM, Wes Freeman <freeman....@gmail.com> wrote:
> You can use predicates with CREATE also, so just add a WHERE oldsu <> null
> at the end.
> At least, I think that's what you're trying to do.
> Wes
> On Wed, Oct 10, 2012 at 4:10 AM, Abdul Azeez Shaik <
> azeeztechni...@gmail.com> wrote:
>> Thats a nice idea. It would make query too very simple.
>> Thanks for the help Wes.
>> Any idea on the other query which i posted on same thread?
>> I tried same query with optional relationship in first subquery, first
>> subquery works fine.
>> However, second sub-query fails due to null in second query.
>> Can we avoid creating second relationship in oldsu is null?
>> Here is the updated query,
>> @Query( "START n=node:search(username={0}) MATCH n-[r?:STATUS]->oldsu
>> DELETE r " +
>> On Wed, Oct 10, 2012 at 12:36 PM, Wes Freeman <freeman....@gmail.com>wrote:
>>> Are status updates linked together via next? Maybe you should just be
>>> querying based on the oldest status update already returned, and then
>>> following that path. For the new status updates, that should be a different
>>> query (I think).
>>> On Wed, Oct 10, 2012 at 2:50 AM, Abdul Azeez Shaik <
>>> azeeztechni...@gmail.com> wrote:
>>>> Hi Wes,
>>>> In between first call and second call if there are 10 more status
>>>> updates, then it returns 10new and 10old(which are already return in first
>>>> call) in second call.
>>>> I am thinking to save posted data from first call and add this
>>>> condition to second call so that query doesn't consider new status updates.
>>>> Please let me know if this can be implemented in some other way.
>>>> Thanks,
>>>> Abdul
>>>> On Wed, Oct 10, 2012 at 12:04 PM, Wes Freeman <freeman....@gmail.com>wrote:
>>>>> You can do:
>>>>> start n=node(1)
>>>>> match n-[:friend]->f-[:status]->s-[:next*0..]->su
>>>>> return su
>>>>> order by su.date desc
>>>>> skip 20
>>>>> limit 20;
>>>>> To skip the first 20, and get 20 more status updates. Then you can
>>>>> keep incrementing skip as you get more.
>>>>> Wes
>>>>> On Wed, Oct 10, 2012 at 2:14 AM, Abdul Azeez Shaik <
>>>>> azeeztechni...@gmail.com> wrote:
>>>>>> Ok, got the first part, got confused unnecessarily.
>>>>>> start n=node(1)
>>>>>> match n-[:friend]->f-[:status]->s-[:next*0..]->su
>>>>>> return su
>>>>>> order by su.date desc;
>>>>>> Thanks for providing me initial help Wes.
>>>>>> Any help on the second part,
>>>>>> Lets say, i limit to 20 updates now. Next time when user wants next
>>>>>> list, i need to get next 20updates, by this time, there might be 10 new
>>>>>> updates, due to this i will get 10old updates(which was already retrieved
>>>>>> in first query).
>>>>>> Is this something that i need to handle after retrieving data?
>>>>>> On Wed, Oct 10, 2012 at 9:48 AM, Abdul Azeez Shaik <
>>>>>> azeeztechni...@gmail.com> wrote:
>>>>>>> Thanks for the prompt response Wes.
>>>>>>> NEXT relationship must also be included, as next.status might be the
>>>>>>> latest one compared to s.status. struggling here to write a one...
>>>>>>> And Lets say, i limit to 20 updates now. Next time when user wants
>>>>>>> next list, i need to get next 20updates, by this time, there might be 10
>>>>>>> new updates, due to this i will get 10old updates(which was already
>>>>>>> retrieved in first query).
>>>>>>> Is this something that i need to handle after retrieving data?
>>>>>>> Thanks,
>>>>>>> Abdul
>>>>>>> On Wed, Oct 10, 2012 at 9:36 AM, Wes Freeman <freeman....@gmail.com>wrote:
>>>>>>>> Something like? (replace 1 with node id of person)
>>>>>>>> start n=node(1)
>>>>>>>> match n-[:friend]->f-[:status]->s
>>>>>>>> return s
>>>>>>>> order by s.date;
>>>>>>>> Wes
>>>>>>>> On Tue, Oct 9, 2012 at 11:48 PM, Abdul Azeez Shaik <
>>>>>>>> azeeztechni...@gmail.com> wrote:
>>>>>>>>> Hi,
>>>>>>>>> Is there any working cypher query to get status updates of friends
>>>>>>>>> (for below model)? (similar to newsfeed in facebook)?
>>>>>>>>> I am using latest SDN and 1.8GA.
>>>>>>>>> In Neo4j documentation, it was given for traversal, am unable to
>>>>>>>>> convert it into cypher query.
>>>>>>>>> If there is any working example code that would be really great.
start n=node:node_auto_index(name="person")
match n-[r?:STATUS]->oldsu
create n-[:STATUS]->(newsu {id:"an id"})
with oldsu, newsu
create newsu-[:NEXT]->oldsu
where oldsu <> null
return newsu;
The trouble with this one is that you can get multiple results back from
the first match, so it will create more than one record with the second
create.
This way you can do:
start n=node:node_auto_index(name="person")
match n-[r?:STATUS]->oldsu
with oldsu,n
order by oldsu.date desc
limit 1
create n-[:STATUS]->(newsu {id:"an id",date:1000000})
with oldsu, newsu
create newsu-[:NEXT]->oldsu
where oldsu <> null
return newsu;
I tested it on my local build and it creates 1 node and 1 relationship the
first time, and then 1 node and 2 relationships the additional times I run
it.
Maybe Michael or Peter know a better way to do it without the new pull
request.
Wes
On Wed, Oct 10, 2012 at 6:57 AM, Abdul Azeez Shaik <azeeztechni...@gmail.com
> wrote:
> That predicate will exclude the complete operation, CREATE
> n-[:STATUS]->(newsu {statusid:{1},statusUpdate:{2}
> ,postedDate:{3}})-[:NEXT]->oldsu
> First relation and node must be created, only second one must get
> excluded.i.e.NEXT relation.
> Thanks,
> Abdul
> On Wed, Oct 10, 2012 at 1:49 PM, Wes Freeman <freeman....@gmail.com>wrote:
>> You can use predicates with CREATE also, so just add a WHERE oldsu <>
>> null at the end.
>> At least, I think that's what you're trying to do.
>> Wes
>> On Wed, Oct 10, 2012 at 4:10 AM, Abdul Azeez Shaik <
>> azeeztechni...@gmail.com> wrote:
>>> Thats a nice idea. It would make query too very simple.
>>> Thanks for the help Wes.
>>> Any idea on the other query which i posted on same thread?
>>> I tried same query with optional relationship in first subquery, first
>>> subquery works fine.
>>> However, second sub-query fails due to null in second query.
>>> Can we avoid creating second relationship in oldsu is null?
>>> Here is the updated query,
>>> @Query( "START n=node:search(username={0}) MATCH n-[r?:STATUS]->oldsu
>>> DELETE r " +
>>> On Wed, Oct 10, 2012 at 12:36 PM, Wes Freeman <freeman....@gmail.com>wrote:
>>>> Are status updates linked together via next? Maybe you should just be
>>>> querying based on the oldest status update already returned, and then
>>>> following that path. For the new status updates, that should be a different
>>>> query (I think).
>>>> On Wed, Oct 10, 2012 at 2:50 AM, Abdul Azeez Shaik <
>>>> azeeztechni...@gmail.com> wrote:
>>>>> Hi Wes,
>>>>> In between first call and second call if there are 10 more status
>>>>> updates, then it returns 10new and 10old(which are already return in first
>>>>> call) in second call.
>>>>> I am thinking to save posted data from first call and add this
>>>>> condition to second call so that query doesn't consider new status updates.
>>>>> Please let me know if this can be implemented in some other way.
>>>>> Thanks,
>>>>> Abdul
>>>>> On Wed, Oct 10, 2012 at 12:04 PM, Wes Freeman <freeman....@gmail.com>wrote:
>>>>>> You can do:
>>>>>> start n=node(1)
>>>>>> match n-[:friend]->f-[:status]->s-[:next*0..]->su
>>>>>> return su
>>>>>> order by su.date desc
>>>>>> skip 20
>>>>>> limit 20;
>>>>>> To skip the first 20, and get 20 more status updates. Then you can
>>>>>> keep incrementing skip as you get more.
>>>>>> Wes
>>>>>> On Wed, Oct 10, 2012 at 2:14 AM, Abdul Azeez Shaik <
>>>>>> azeeztechni...@gmail.com> wrote:
>>>>>>> Ok, got the first part, got confused unnecessarily.
>>>>>>> start n=node(1)
>>>>>>> match n-[:friend]->f-[:status]->s-[:next*0..]->su
>>>>>>> return su
>>>>>>> order by su.date desc;
>>>>>>> Thanks for providing me initial help Wes.
>>>>>>> Any help on the second part,
>>>>>>> Lets say, i limit to 20 updates now. Next time when user wants next
>>>>>>> list, i need to get next 20updates, by this time, there might be 10 new
>>>>>>> updates, due to this i will get 10old updates(which was already retrieved
>>>>>>> in first query).
>>>>>>> Is this something that i need to handle after retrieving data?
>>>>>>> On Wed, Oct 10, 2012 at 9:48 AM, Abdul Azeez Shaik <
>>>>>>> azeeztechni...@gmail.com> wrote:
>>>>>>>> Thanks for the prompt response Wes.
>>>>>>>> NEXT relationship must also be included, as next.status might be
>>>>>>>> the latest one compared to s.status. struggling here to write a one...
>>>>>>>> And Lets say, i limit to 20 updates now. Next time when user wants
>>>>>>>> next list, i need to get next 20updates, by this time, there might be 10
>>>>>>>> new updates, due to this i will get 10old updates(which was already
>>>>>>>> retrieved in first query).
>>>>>>>> Is this something that i need to handle after retrieving data?
>>>>>>>> Thanks,
>>>>>>>> Abdul
>>>>>>>> On Wed, Oct 10, 2012 at 9:36 AM, Wes Freeman <freeman....@gmail.com
>>>>>>>> > wrote:
>>>>>>>>> Something like? (replace 1 with node id of person)
>>>>>>>>> start n=node(1)
>>>>>>>>> match n-[:friend]->f-[:status]->s
>>>>>>>>> return s
>>>>>>>>> order by s.date;
>>>>>>>>> Wes
>>>>>>>>> On Tue, Oct 9, 2012 at 11:48 PM, Abdul Azeez Shaik <
>>>>>>>>> azeeztechni...@gmail.com> wrote:
>>>>>>>>>> Hi,
>>>>>>>>>> Is there any working cypher query to get status updates of
>>>>>>>>>> friends (for below model)? (similar to newsfeed in facebook)?
>>>>>>>>>> I am using latest SDN and 1.8GA.
>>>>>>>>>> In Neo4j documentation, it was given for traversal, am unable to
>>>>>>>>>> convert it into cypher query.
>>>>>>>>>> If there is any working example code that would be really great.
Thats awesome Wes. I tried it just now and it worked like champ.
This query also makes sure that there is only one node with 'STATUS
relationship, so, first match always returns single result.
On Wed, Oct 10, 2012 at 7:32 PM, Wes Freeman <freeman....@gmail.com> wrote:
> So, this is the closest I can get it:
> start n=node:node_auto_index(name="person")
> match n-[r?:STATUS]->oldsu
> create n-[:STATUS]->(newsu {id:"an id"})
> with oldsu, newsu
> create newsu-[:NEXT]->oldsu
> where oldsu <> null
> return newsu;
> The trouble with this one is that you can get multiple results back from
> the first match, so it will create more than one record with the second
> create.
> In my latest pull request, there is a way to limit and order after a with
> statement, which I think might actually help here:
> https://github.com/neo4j/community/pull/913
> This way you can do:
> start n=node:node_auto_index(name="person")
> match n-[r?:STATUS]->oldsu
> with oldsu,n
> order by oldsu.date desc
> limit 1
> create n-[:STATUS]->(newsu {id:"an id",date:1000000})
> with oldsu, newsu
> create newsu-[:NEXT]->oldsu
> where oldsu <> null
> return newsu;
> I tested it on my local build and it creates 1 node and 1 relationship the
> first time, and then 1 node and 2 relationships the additional times I run
> it.
> Maybe Michael or Peter know a better way to do it without the new pull
> request.
> Wes
> On Wed, Oct 10, 2012 at 6:57 AM, Abdul Azeez Shaik <
> azeeztechni...@gmail.com> wrote:
>> That predicate will exclude the complete operation, CREATE
>> n-[:STATUS]->(newsu {statusid:{1},statusUpdate:{2}
>> ,postedDate:{3}})-[:NEXT]->oldsu
>> First relation and node must be created, only second one must get
>> excluded.i.e.NEXT relation.
>> Thanks,
>> Abdul
>> On Wed, Oct 10, 2012 at 1:49 PM, Wes Freeman <freeman....@gmail.com>wrote:
>>> You can use predicates with CREATE also, so just add a WHERE oldsu <>
>>> null at the end.
>>> At least, I think that's what you're trying to do.
>>> Wes
>>> On Wed, Oct 10, 2012 at 4:10 AM, Abdul Azeez Shaik <
>>> azeeztechni...@gmail.com> wrote:
>>>> Thats a nice idea. It would make query too very simple.
>>>> Thanks for the help Wes.
>>>> Any idea on the other query which i posted on same thread?
>>>> I tried same query with optional relationship in first subquery, first
>>>> subquery works fine.
>>>> However, second sub-query fails due to null in second query.
>>>> Can we avoid creating second relationship in oldsu is null?
>>>> Here is the updated query,
>>>> @Query( "START n=node:search(username={0}) MATCH n-[r?:STATUS]->oldsu
>>>> DELETE r " +
>>>> On Wed, Oct 10, 2012 at 12:36 PM, Wes Freeman <freeman....@gmail.com>wrote:
>>>>> Are status updates linked together via next? Maybe you should just be
>>>>> querying based on the oldest status update already returned, and then
>>>>> following that path. For the new status updates, that should be a different
>>>>> query (I think).
>>>>> On Wed, Oct 10, 2012 at 2:50 AM, Abdul Azeez Shaik <
>>>>> azeeztechni...@gmail.com> wrote:
>>>>>> Hi Wes,
>>>>>> In between first call and second call if there are 10 more status
>>>>>> updates, then it returns 10new and 10old(which are already return in first
>>>>>> call) in second call.
>>>>>> I am thinking to save posted data from first call and add this
>>>>>> condition to second call so that query doesn't consider new status updates.
>>>>>> Please let me know if this can be implemented in some other way.
>>>>>> Thanks,
>>>>>> Abdul
>>>>>> On Wed, Oct 10, 2012 at 12:04 PM, Wes Freeman <freeman....@gmail.com>wrote:
>>>>>>> You can do:
>>>>>>> start n=node(1)
>>>>>>> match n-[:friend]->f-[:status]->s-[:next*0..]->su
>>>>>>> return su
>>>>>>> order by su.date desc
>>>>>>> skip 20
>>>>>>> limit 20;
>>>>>>> To skip the first 20, and get 20 more status updates. Then you can
>>>>>>> keep incrementing skip as you get more.
>>>>>>> Wes
>>>>>>> On Wed, Oct 10, 2012 at 2:14 AM, Abdul Azeez Shaik <
>>>>>>> azeeztechni...@gmail.com> wrote:
>>>>>>>> Ok, got the first part, got confused unnecessarily.
>>>>>>>> start n=node(1)
>>>>>>>> match n-[:friend]->f-[:status]->s-[:next*0..]->su
>>>>>>>> return su
>>>>>>>> order by su.date desc;
>>>>>>>> Thanks for providing me initial help Wes.
>>>>>>>> Any help on the second part,
>>>>>>>> Lets say, i limit to 20 updates now. Next time when user wants next
>>>>>>>> list, i need to get next 20updates, by this time, there might be 10 new
>>>>>>>> updates, due to this i will get 10old updates(which was already retrieved
>>>>>>>> in first query).
>>>>>>>> Is this something that i need to handle after retrieving data?
>>>>>>>> On Wed, Oct 10, 2012 at 9:48 AM, Abdul Azeez Shaik <
>>>>>>>> azeeztechni...@gmail.com> wrote:
>>>>>>>>> Thanks for the prompt response Wes.
>>>>>>>>> NEXT relationship must also be included, as next.status might be
>>>>>>>>> the latest one compared to s.status. struggling here to write a one...
>>>>>>>>> And Lets say, i limit to 20 updates now. Next time when user wants
>>>>>>>>> next list, i need to get next 20updates, by this time, there might be 10
>>>>>>>>> new updates, due to this i will get 10old updates(which was already
>>>>>>>>> retrieved in first query).
>>>>>>>>> Is this something that i need to handle after retrieving data?
>>>>>>>>> Thanks,
>>>>>>>>> Abdul
>>>>>>>>> On Wed, Oct 10, 2012 at 9:36 AM, Wes Freeman <
>>>>>>>>> freeman....@gmail.com> wrote:
>>>>>>>>>> Something like? (replace 1 with node id of person)
>>>>>>>>>> start n=node(1)
>>>>>>>>>> match n-[:friend]->f-[:status]->s
>>>>>>>>>> return s
>>>>>>>>>> order by s.date;
>>>>>>>>>> Wes
>>>>>>>>>> On Tue, Oct 9, 2012 at 11:48 PM, Abdul Azeez Shaik <
>>>>>>>>>> azeeztechni...@gmail.com> wrote:
>>>>>>>>>>> Hi,
>>>>>>>>>>> Is there any working cypher query to get status updates of
>>>>>>>>>>> friends (for below model)? (similar to newsfeed in facebook)?
>>>>>>>>>>> I am using latest SDN and 1.8GA.
>>>>>>>>>>> In Neo4j documentation, it was given for traversal, am unable to
>>>>>>>>>>> convert it into cypher query.
>>>>>>>>>>> If there is any working example code that would be really great.