• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Apache Lucene searching and highlighting

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am making a small project in Apache Lucene, that searches for words in different type of files: pdf, html, txt. I used the highlighter library to highlight the found words, but this library marks all the found words, in the whole content. I would like to do something like this, something similar to how google displays the results:

If I search for some words, I would like to display a part of the text that contains all of them, also highlighted. If they aren't close enough (5 words for ex), to display only the first appeareance of every word: If I search for the 1st word the 2nd word, to display something like this:

xyz abcd <the 1st word>.........<the 2nd word> abcd abc
This is my code right now:

How could I do this? Thanks!
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic