lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Lynch, Pat" <Pat.Ly...@Polycom.com>
Subject How do I get the location within a file for a search result?
Date Sat, 22 Apr 2017 16:47:53 GMT
Hello,

 

I'm brand new to Lucene.  I've tried looking through a variety of on-line
tutorials but they point to methods that are deprecated or no longer exist,
such as  TokenSources.getAnyTokenStream().

 

I've also tried browsing the archives for this mailing list, but I don't
have time to browse them all and ironically, the archives do not appear to
be searchable.

 

The deprecated methods have not worked for me.  They seem to depend on the
field being stored in the index.  My problem is that the files I'm indexing
are anywhere from 6Mb to 15Mb in size and there are dozens of them.  The
content is what I need to search, not so much the meta-data stored in the
indexed fields.

 

The demo code (SearchFiles) demonstrates showing the results with the title,
path and score, but not the location within the file where the hit was
found.

 

Can anyone assist me with a pointer to an example or a hint at what I need
to do to get the file positions?

 

Thanks!

-Pat

 

Here's a snippet I'm using to create the indexed documents:

 

      final Document document = new Document();

      final Field contentField = new TextField("contents", new
FileReader(file));

      final Field fileNameField = new StringField("filename",
file.getName(), Field.Store.YES);

      final Field filePathField = new StringField("filepath",
file.getCanonicalPath(), Field.Store.YES);

 

      document.add(contentField);

      document.add(fileNameField);

      document.add(filePathField);


Mime
View raw message