raj
raj

Reputation: 3811

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.

Upvotes: 1

Views: 890

Answers (1)

Fred Foo
Fred Foo

Reputation: 363487

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.)

Upvotes: 1

Related Questions