lucene : how to get a line of occurence of query
I have a number of text files. Each text files have data like this :
<text> Big data... big data... </text>
<text> another big data </text>
<text> some other data </text>
now I have to write a code with lucene that could retrieve the entire line when a search query matches,
like if i search for some data
the entire third line should be filtered.
<text> some other data </text>
I've been able to do开发者_高级运维 a little with spanQuery, but that returns me only documents and the word positions. how do i get the "real text" from the text file ?
Kindly give reference materials if available.
I'm not sure what you mean. If it's always enough for you to retrieve only a single line, then you may want to create one Document
per line instead of per file.
Then IndexReader.document
will retrieve only the line in question. (Mapping back from lines to files will be more complicated, of course.)
精彩评论