In RavenDB my document (ID = 1234) is
"datacontainer": {
"data": [
{
"@idx": "1",
"@idy": "a",
"value": {
"#text": "test 2010"
}
},
{
"@idx": "2",
"@idy": "b",
"value": {
"#text": "test 2011"
}
},
{
"@idx": "3",
"@idy": "c",
"value": {
"#text": "test 2012"
}
}
]
}
I want to create an Index, where I choose my favourite values (for example idx = "2" and idy = "b") and the output will be:
(ID, value_text) = (1234, "test 2011")
Now I can select a single element and check its value in Linq:
where p.datacontainer.data[0]["@idx"] == "2" && p.datacontainer.data[0]["@idy"] == "b"
How can I search the right element in my list?
I solved my problem! In RavenDB the index, called “MyIndex”, is:
Map:
Reduce:
Now I can use this Index in my queries, so I will search for a document that contains a particular value, for example:
Maybe there is a better solution, but now it works!