Lucene .Net- What is a good method for creating index that is more complicated that key/value?
I'm starting a project in which we are trying to index the contents of XML documents with Lucene .Net. In the little documentation I have found it seems that indexes can only consist of fileds with a single string value. The data that I am attempting to index is slightly more complicated than simple key value pairs.
Here is an example of an xml document I would want to generate an index from:
<descriptor>
<asset guid="2AA7C8F9-2CB1-4A81-9421-C09F1D85939E" generated-date="2011-07-30" generated-by="hw/AutoMfg" generated-with="PMS">
<!-- information about where the asset can be used -->
<target>
<localization>en-us</localization>
<localization>es-us</localization>
<environment>desktop</environment>
<environment>mobile</environment>
</target>
<!-- all contents of an asset must have the same version -->
<version-information>
<version-number source="content">9.1.123.4</version-number>
<version-number source="manufacturing">9.1.123.4</version-number>
<release-label>9.1</release-label>
</version-information>
<!-- catalog information about the primary role of the asset -->
<role>
<namespace>parent.type.family.some.thing</namespace>
<mime-type>text/html</mime-type>
<hwid>abc1234</hwid>
</role>
</asset>
</descr开发者_如何学Goiptor>
So I could see create fields named after the child elements of 'descriptor' but what about the child nodes there within? How can this data be indexed? Should I create a delimited string to represent the values of each fields?
eg field: "Target" Value:"localization: en-us;es-us environment: desktop;mobile | ...
Do I need to flatten my data out like in my example above to index it?
Thanks!
Kind of tricky to give specific advice -- so much of it revolves around what you want to retrieve and how rather than the shape of the data. In any case, I would start with Simone Chiaretta's excellent little series on lucene.net (1 2 3 4 5). One concept that will help alot is the fact that you can index the same field multiple times for a given document, so you'll probably make something like:
Target-Localization:en-us
Target-Localization:es-us
Target-Environment:desktop
Target-Environment:mobile
Lucene is fundamentally flat, but capable of being deep while being flat in new and interesting ways.
Take a look at Digester + Lucene. The .NET port of Digester is NDigester
精彩评论