I'm fairly new to RavenDB and Lucene, so hoping that someone can help
me out with how to create this index.
Our core Product object has a collection of Attributes, which are
essentially a dynamic set of key/value pairs with information on the
product -- and the set of keys in the list varies from one product to
the next. I need to figure out how to create an Lucene index on the
values in that collection.
A simple version of the document (and in actuality, you may be looking
at more like 50 AttributeValue objects and a series of other
collections besides):
{
"ProductId": 4,
"SiteId": 8,
"AttributeValues": {
"$type":
"System.Collections.Generic.List`1[[ABC.XYZ.AttributeValue,
ABC.Core]], mscorlib",
"$values": [
{
"AttributeId": 1,
"AttributeName": "Description",
"Value": "My Product Description",
"Id": null
},
{
"AttributeId": 2,
"AttributeName": "Is On Sale",
"Value": "No",
"Id": null
},
{
"AttributeId": 4,
"AttributeName": "Color",
"Value": "Green",
"Id": null
}
]
}
}
Easy enough to create an index on, say, the product id, but can't
quite figure out the collection.
I did find this:
http://codeofrob.com/archive/2010/12/21/ravendb-document-design-with-collections.aspx
which opened up the idea of making AttributeValue a separate document
with a product id property and getting the complete object in two
separate pulls, but while that would certainly make the indexing far
more trivial, I'm not comfortable creating a document from something
that is most definitely not an aggregate root.
Thoughts?
Tim