Note that the don’t care wouldn’t be a null, but rather {} or something like that, per the docs I pointed to @itay
That’s correct @envitraux , it only really works for hierarchical results, but you can do the union/difference at the app side with multiple views.
I’m not sure if that’s what @itay was looking for.
itay
March 4, 2015, 7:56pm
22
I was just looking for a way to query a view with partial compound key.
@ingenthr , I guess that null values will not work.
Alternatively, can someone guide me on how to use the startkey and endkey to span the entire range using unicode. This should do it I guess ? @jmorris ?
Is using several views, e.g. a view with [FirstName, FamilyName, Age] anda view with just [FirstName, Age] better than using only [FirstName, FamilyName, Age] ?
I am not sure if you can, this works:
var query = bucket.CreateQuery("beer", "brewery_beers")
.StartKey("[\"21st_amendment_brewery_cafe\"]", false)
.EndKey("[\"U+0000\"]", false);
The query engine gives a query_parse_error for this:
var query = bucket.CreateQuery("beer", "brewery_beers")
.StartKey("[\"21st_amendment_brewery_cafe\"]", false)
.EndKey("[]", false);
And this:
var query = bucket.CreateQuery("beer", "brewery_beers").
StartKey("[\"21st_amendment_brewery_cafe\"]", false).
EndKey(new object[]{}, true)
The request generated for last two look like this:
http://127.0.0.1:8092/beer-sample/_design/beer/_view/brewery_beers?endkey=[]&limit=10&startkey=["21st_amendment_brewery_cafe"]
If you pass null for endKey it is omitted by the client. In this case what should endkey look like?
-Jeff
itay
March 4, 2015, 8:25pm
24
Thanks Jeff.
I still don"t understand how can I find my older than 20 years old John from:
itay:
How can I use this “Don’t care” state if the compound key has 3 parts and I want the first one to be “John”, the second, let’s say, family name, is a don’t care as I am looking for all the Johns, regardless of the family name, and the third part, the age, should be more than 20 (integer).
Can I use:
startkey= [“John”, null, 20]
endkey = [“John”, null, null] ?
the map emits [doc.FirstName, doc.FamilyName, doc.Age]
I think you would need a view with a different key structure like:
emits [doc.FirstName, doc.Age, doc.FamilyName]
with
startkey= [“John”, 20, null]
endkey = [“John”, 20, 0xFFFF ]
The bottom line is that you one view can really only do one thing, so you need multiple views. In SQL terms a “view” is not the same thing as SQL view but more like an Index
itay
March 5, 2015, 2:35pm
26
Thanks,
How can I enter 0xFFFF in C# ?
new object[] {“John”, 20, ???} ?