简体   繁体   中英

How to add metadata to a lucene field

During indexing of documents, I need to store some metadata to fields.

For example:

  1. I add the field new Field("myField", "myValue", ...) to the document
  2. Now I need to store some kind of metadata (like the type of 'myValue' type) to that field.
  3. This metadata should be indexed as well and stored associated to that field, so searching by the value or the metadata should result in the same set of documents.
  4. Querying all values of myField will return a list of all indexed values supplemented with that metadata.

Is this possible at all? (May be I should better use some kind of database, but I have to use Lucene.)

Thanks in advance


Concrete Example:

I have SVG-documents (XML)

Any of that documents gets fields of type "component" with the values "X35" , "Z89" and many more

I need to store some metadata to "X35" , "Z89" and other:

 X35 => description="My X35 component", sizeX=10, sizeY=20<br>
 Z89 => description="Z89 part", usage_note="...."<br>

and so on

After doing some further research, I think, that it is not possible at all. I really should use a RDBMS ... ;)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM