A view with compound key

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.

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

Thanks Jeff.

I still don"t understand how can I find my older than 20 years old John from:

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

Thanks,
How can I enter 0xFFFF in C# ?
new object[] {“John”, 20, ???} ?