just like Jeff said, it will work using a simple equality filter

you can find who's friend with 1 *or* 2 using IN (eg: who is friend with 1,
2 *or* 3)
if you need to find who's friend with 1 *and* 2, query using 2 equality
filters

anyway, be careful with lists... if you have 2 friends following someone at
the same time you can loose some followers due to concurrent writes, which
can also lead to datastore contention

I would also encourage you to create a new domain with these keys
information, so you wont need to write at the same entity list, you can just
add or remove record



On Tue, Jul 19, 2011 at 10:00 PM, Jeff Schnitzer <j...@infohazard.org>wrote:

> It's actually much simpler than you realize.  Assuming that your List<Long>
> is an indexed property named 'friends', you just need to filter entities for
> 'friends' equal to your id.
>
> This is how list indexes work - if you filter on the property, the entity
> matches if any value in the list matches the filter.
>
> Jeff
>
>
> On Tue, Jul 19, 2011 at 5:28 PM, keyvez <key...@gmail.com> wrote:
>
>> Thanks for your quick response. After looking into the IN operator, it
>> doesn't seem to be what I need. My table looks like this.
>>
>>
>> User table:
>> id   friends
>> 1    5
>> 2    1, 4
>> 3    1
>> 4    1, 2
>> 5    1
>>
>> I would like to find out who are user 1's friends so the query would be
>> something like this
>>
>> SELECT * FROM User WHERE friends.contains(1)
>>
>> the IN version looks like this
>>
>> SELECT * FROM User WHERE friends IN (1)
>>
>> which would return id=3 as a result but it is wrong, I am expecting to
>> see id=2,3,4 be returned in the result set. Because they are all friends
>> with one.
>>
>> Also I HAVE to do this through the low level datastore API to utilize the
>> cursor feature.
>>
>> Thanks,
>> Gaurav
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Google App Engine for Java" group.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msg/google-appengine-java/-/XV-oATd4fjUJ.
>>
>> To post to this group, send email to
>> google-appengine-java@googlegroups.com.
>> To unsubscribe from this group, send email to
>> google-appengine-java+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/google-appengine-java?hl=en.
>>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Google App Engine for Java" group.
> To post to this group, send email to
> google-appengine-java@googlegroups.com.
> To unsubscribe from this group, send email to
> google-appengine-java+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/google-appengine-java?hl=en.
>



-- 
Bruno Fuster

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine for Java" group.
To post to this group, send email to google-appengine-java@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine-java+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en.

Reply via email to