TransWikia.com

How to return the index of multi value field in the search results in Lucene?

Stack Overflow Asked by Dmitriy Dumanskiy on December 18, 2021

I have a document that contains tags field, I add it like this:

for (Tag tag : tags) { //rock, disco, jazz
   fields.add(new StringField("Tag", tag.name, Field.Store.YES))
}

Now, when I perform the search I would like to get not only document that has a tag, but also specific index within the Tag field that matches the query.
For, example, now when I search for jazz I need also within search results index=2. To know exact tag that was matched (because I use also prefix search and phrase search).

How can I achieve that with Lucene?

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP