On Sep 29, 2014, at 10:16 PM, peng liu <liup...@gmail.com> wrote:i have a user model. and has "pro" and "older",i want query "pro> 75 and 5<older<10" ,how to do that on couchbase ios? i have try set startKey and endKey but not work.
--
You received this message because you are subscribed to the Google Groups "Couchbase Mobile" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mobile-couchba...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/mobile-couchbase/0a546216-5b77-4286-852a-0dcf8f569842%40googlegroups.com.
Todd
That's great. Let me know if I can help in encoding and posting to a site for others.
Todd
--
You received this message because you are subscribed to the Google Groups "Couchbase Mobile" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mobile-couchba...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/mobile-couchbase/e97ba4e6-9946-402a-94ad-402ece5aa134%40googlegroups.com.
sqlite> select *from revs;
1|1|1-2fc730769d3a7ff64c7e3e512cadb12a||0|0|{"contactData":"Tel: +4912342340","progress":75,"type":"contacInfo","userOlder":8,"user_id":"N_older_Pro_0"}|1
2|2|1-554a468df052a997bca3a64a40a9b06d||1|0|{"contactData":"Tel: +4912342341","progress":76,"type":"contacInfo","userOlder":5,"user_id":"N_older_Pro_1"}|1
3|3|1-e550947cda089edd35170c49c6d1023b||1|0|{"contactData":"Tel: +4912342342","progress":65,"type":"contacInfo","userOlder":9,"user_id":"N_older_Pro_2"}|1
4|4|1-0601c2e7054bd8f1c21f26c9ebd93c3a||1|0|{"contactData":"Tel: +4912342343","progress":60,"type":"contacInfo","userOlder":8,"user_id":"N_older_Pro_3"}|1
5|1|2-599f9eb423907d211eb7ca6ebc597ba6|1|1|0|{"contactData":"Tel: +4912342340","progress":75,"type":"contacInfo","userOlder":8,"user_id":"N_older_Pro_0"}|1
6|5|1-f20c5c37c10192ac46cf67e53eb26a70||1|0|{"contactData":"Tel: +4912342343_1","progress":35,"type":"contacInfo","userOlder":1,"user_id":"N_older_Pro_4"}|1
7|6|1-f88596fb5c22efb73407c4aa6b3dd2c3||1|0|{"contactData":"Tel: +4912342343","progress":8,"type":"contacInfo","userOlder":8,"user_id":"N_older_Pro_10"}|1
8|7|1-8f55890cb67557a0f18ba5f852fca07f||1|0|{"contactData":"Tel: +4912342343","progress":8,"type":"contacInfo","userOlder":0,"user_id":"N_older_Pro_11"}|1
and then query it :
(Querying pro:60 older: 2 ,3)
CBLView * contactInfoView = [self.database viewNamed: @"contactDataByProgressAndOlder"];
[contactInfoView setMapBlock: MAPBLOCK({
if ([doc[@"type"] isEqualToString: @"contacInfo"]) {
if (doc[@"progress"] && doc[@"userOlder"])
emit(@[doc[@"progress"], doc[@"userOlder"]], doc);
}
}) version: @"3"];
//2 - make the query
CBLQuery* query = [contactInfoView createQuery];
NSLog(@"Querying pro:%@ older: %@ ,%@",pro, startOlder,endOlder);
query.startKey = @[pro,startOlder];
query.endKey = @[[NSNumber numberWithInteger: 75], endOlder];
return query;
and wrong result:
2014-10-30 21:36:40.068 TestCLDB[851:24414] Querying pro:60 older: 2 ,3
2014-10-30 21:36:40.070 TestCLDB[851:24414] Found document: CBLDocument[N_ol..ro_3] ,{
"_id" = "N_older_Pro_3";
"_rev" = "1-0601c2e7054bd8f1c21f26c9ebd93c3a";
contactData = "Tel: +4912342343";
progress = 60;
type = contacInfo;
userOlder = 8;
"user_id" = "N_older_Pro_3";
}
2014-10-30 21:36:40.070 TestCLDB[851:24414] Found document: CBLDocument[N_ol..ro_2] ,{
"_id" = "N_older_Pro_2";
"_rev" = "1-e550947cda089edd35170c49c6d1023b";
contactData = "Tel: +4912342342";
progress = 65;
type = contacInfo;
userOlder = 9;
"user_id" = "N_older_Pro_2";
}
But i query (Querying pro:60 older: 8 ,10) it's run success:
2014-10-30 21:58:40.343 TestCLDB[987:41693] Querying pro:60 older: 8 ,10
2014-10-30 21:58:40.348 TestCLDB[987:41693] Found document: CBLDocument[N_ol..ro_3] ,{
"_id" = "N_older_Pro_3";
"_rev" = "1-0601c2e7054bd8f1c21f26c9ebd93c3a";
contactData = "Tel: +4912342343";
progress = 60;
type = contacInfo;
userOlder = 8;
"user_id" = "N_older_Pro_3";
}
2014-10-30 21:58:40.348 TestCLDB[987:41693] Found document: CBLDocument[N_ol..ro_2] ,{
"_id" = "N_older_Pro_2";
"_rev" = "1-e550947cda089edd35170c49c6d1023b";
contactData = "Tel: +4912342342";
progress = 65;
type = contacInfo;
userOlder = 9;
"user_id" = "N_older_Pro_2";
}
2014-10-30 21:58:40.349 TestCLDB[987:41693] Found document: CBLDocument[N_ol..ro_0] ,{
"_id" = "N_older_Pro_0";
"_rev" = "2-599f9eb423907d211eb7ca6ebc597ba6";
contactData = "Tel: +4912342340";
progress = 75;
type = contacInfo;
userOlder = 8;
"user_id" = "N_older_Pro_0";
}
On Thursday, October 30, 2014 12:20:32 AM UTC-7, peng liu wrote:
by the way . where is " feature/query" ? i
thanks
As you said.it's not support two keys to create a range.and i can filter a first keys ,and then get the first result then filter second keys .it same work.
but if the first range not get any result,at this time how to filter second keys ?
so .i do not think it's a good idea.
thanks
On Oct 29, 2014, at 11:58 PM, peng liu <liup...@gmail.com> wrote:As you said.it's not support two keys to create a range.and i can filter a first keys ,and then get the first result then filter second keys .it same work.but if the first range not get any result,at this time how to filter second keys ?so .i do not think it's a good idea.
On Oct 30, 2014, at 6:30 PM, peng liu <liup...@gmail.com> wrote:i know this. but i really need do like this. if i query first key and query second key ,and then filter the results to my final result. it will so slowly if my data large. so ,may be the couch base can not do like this .because i query some like this (query (A > x and B = y ) or C < w)) often. so only sql may be do this better that i think.
But sql will be sync by myself between android and iOS or wp.. the data will be large. this is the only reason that i use couch base.