1

i have a single document in lucene index with multiple fields and some of the fields are multivalued for example

Document{ field1: field2: field3: .... field9:}

and fields are like

field1:some string value
field2:some int value
.
.
.
field8:(string values that are space separated and each is a token )//uid for some items
field9:(value or items whose uid is in field8 and both field8 and field9 are one to one map)

With this i am able to search and index a multivalued field in a flat document structure now i have an other field say field10: in which i have multiple values against a single uid in field8 then how can i index and search this new field in this structure using lucene

i want to index and then map the field10 values against field8, for example

field8: {     uid1    | uid2     | uid3} 
field10:{id1,id2,id3  | id1,id7  | id1 }

help required regards

jakub.g
  • 38,512
  • 12
  • 92
  • 130
Badr
  • 10,384
  • 15
  • 70
  • 104

1 Answers1

0

Here's what I think you're asking. Suppose you have a document like:

field8:  {    1    |    2    |    3    }
field10: { foo,bar | baz,foo | bar,baz }

You want to have the query +field8:1 +field10:foo return this document, but +field8:3 +field10:foo shouldn't return the document.

This is a relational data model, and it's not something Lucene tries to be good at. Your best bet is to use a relational database.

If you want to stick with Lucene, you should split each one of these fields into its own document. So one doc would be field8:1, field10: foo,bar etc. Alternatively you could have your own tokenizer which used payloads or term positions to handle this. I don't know that it would be particularly easy or fast.

There are many questions on this site regarding your problem, e.g. Storing relational data in a Lucene.NET index

Community
  • 1
  • 1
Xodarap
  • 11,581
  • 11
  • 56
  • 94