Lucene: how to index file names

I'm newbie lucene user and trying to get some basics now. I have three files: - `apache_empty.txt` (empty file), - `apache.txt` (contains many of `'apache'` tokens), - `other.txt` (contains just one token - `'apache'`) When I try to search `'apache'`, **I get only** `apache.txt` and `other.txt` in result, but I wanna get even the `apache_empty.txt` file, which has the searched word in its name... And that's how I add documents to the index: protected Document getDocument(File f) throws Exception { Document doc = new Document(); Field contents = new Field("contents", new FileReader(f)); Field parent = new Field("parent", f.getParent(), Field.Store.YES, Field.Index.NOT_ANALYZED); Field filename = new Field("filename", f.getName(), Field.Store.YES, Field.Index.ANALYZED); Field fullpath = new Field("fullpath", f.getCanonicalPath(), Field.Store.YES, Field.Index.NOT_ANALYZED); filename.setBoost(2.0F); doc.add(contents); doc.add(parent); doc.add(filename); doc.add(fullpath); return doc; } How to let the lucene index also file names?

以上就是Lucene: how to index file names的详细内容,更多请关注web前端其它相关文章!

赞(0) 打赏
未经允许不得转载:web前端首页 » JavaScript 答疑

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

前端开发相关广告投放 更专业 更精准