0

I wanted to ask if there is a quick way of getting content of a document into a single document field. All the examples i have seen have relatively short strings. I cannot save an entire journal article into a string and indexthat is there a quick way of telling lucene to index all the words in a file? I am using Lucene.net 3.03 for this application.

pnuts
  • 58,317
  • 11
  • 87
  • 139
TheCodeNovice
  • 750
  • 14
  • 35

2 Answers2

0

There is not an easy way to pass just the file, you have to provide the entire content to lucene to made the indexing for the search. Here is a answer from the Q/A about indexing PDF, but is the same from every type of document, just open it and index to lucene.

Community
  • 1
  • 1
sebmaldo
  • 59
  • 7
0

You can just pass a System.IO.TextReader to a Field. If the file is plain text, or something like it, you should just be able to open the Reader on it, and pass it directly into the Field, like:

System.IO.TextReader reader = new StreamReader("path/to/my/file.txt");
Field field = new Field("fieldName", reader);
document.add(field);
femtoRgon
  • 32,893
  • 7
  • 60
  • 87