If I understand correctly, you want an arbitrary number of related addresses, retrievable separately, but searchable simply as:
address:"my address"
I would recommend storing addresses named whatever you like (I will use 'address1' and 'address2' here), and accumulating their text into one big old 'address' field. Something like:
doc.add(new Field("key", "1", Field.Store.YES, Field.Index.ANALYZED));
doc.add(new Field("name", "sam", Field.Store.YES, Field.Index.ANALYZED));
doc.add(new Field("address", "lane no 1 behind la gardens near abc cross main road", Field.Store.NO, Field.Index.ANALYZED));
//Note, that you can add multiple fields with the same name, and it will effectively be merged together, as:
doc.add(new Field("address", "more address information for searching", Field.Store.NO, Field.Index.ANALYZED));
doc.add(new Field("address1", "lane no 1 behind la gardens", Field.Store.YES, Field.Index.NO));
doc.add(new Field("address2", "near abc cross main road", Field.Store.YES, Field.Index.NO));
Note that address is passed Field.Store.NO
and Field.Index.ANALYZED
, while address1 and address2 are passed Field.Store.YES
and Field.Index.NO
. So you search on 'address', but never on 'address1' or 'address2', and you retrieve 'address1' and 'address2' from found documents, but never 'address'