You're describing what I call the "cross matching" problem if you flatten nested, repeating structures with multiple fields into a single flat Lucene document model. The approach for handling the more complex mappings is to use nested child docs in Lucene and for that look at BlockJoinQuery.
However, in this particular case it just might be possible to safely collapse your Json doc into a single Lucene doc if the value for "fields.id" (e.g. L31A) was used as the Lucene field name on a single document and the related "value" field was the Lucene field's contents. Of course you can only go so far with this sort of flattening approach before cross-matching becomes an issue. Cheers Mark On 21 May 2012, at 19:36, Mohit Anchlia wrote: > I am new to search and just went through some concepts of "Lucene in > Action". I have few questions: > > Problem I am having is this. Say I have these json docs for eg. Now I want > to query forms.id = 40 and fields.id = L31A and fields.value = 3000. I > expect it to return doc 1. But with the regular search I'll also get doc 2. > What's the best way of designing search for such queries? > > Json doc 1 > { > "fileName":"filename", > "createdDate":"05/20/12 16:21:56", > "setModel":[ > { > "id":"1", > "compliance":false, > "forms":[ > { > "id":"40", > "copy":null, > "tpsId":null, > "forms":[ > { > "id":"F40_SW_2", > "copy":null, > "tpsId":"1[]/F40[]", > "forms":[ > ], > "tables":[ > ], > "fields":[ > { > "id":"L31A", > "security":null, > "value":"3000." > }, > { > "id":"MRSSN1", > "security":null, > "value":"656465464" > } > ] > } > ] > } > } > > > Json doc 2 > { > "fileName":"filename", > "createdDate":"05/20/12 16:21:56", > "setModel":[ > { > "id":"1", > "compliance":false, > "forms":[ > { > "id":"50", > "copy":null, > "tpsId":null, > "forms":[ > { > "id":"F50_SW_2", > "copy":null, > "tpsId":"1[]/F50[]", > "forms":[ > ], > "tables":[ > ], > "fields":[ > { > "id":"L31A", > "security":null, > "value":"3000." > }, > { > "id":"MRSSN1", > "security":null, > "value":"656465464" > } > ] > } > ] > } --------------------------------------------------------------------- To unsubscribe, e-mail: java-user-unsubscr...@lucene.apache.org For additional commands, e-mail: java-user-h...@lucene.apache.org