The logical representation of a {@link Lucene.Net.Documents.Document} for indexing and searching.

The document package provides the user level logical representation of content to be indexed and searched. The package also provides utilities for working with {@link Lucene.Net.Documents.Document}s and {@link Lucene.Net.Documents.Fieldable}s.

Document and Fieldable

A {@link Lucene.Net.Documents.Document} is a collection of {@link Lucene.Net.Documents.Fieldable}s. A {@link Lucene.Net.Documents.Fieldable} is a logical representation of a user's content that needs to be indexed or stored. {@link Lucene.Net.Documents.Fieldable}s have a number of properties that tell Lucene how to treat the content (like indexed, tokenized, stored, etc.) See the {@link Lucene.Net.Documents.Field} implementation of {@link Lucene.Net.Documents.Fieldable} for specifics on these properties.

Note: it is common to refer to {@link Lucene.Net.Documents.Document}s having {@link Lucene.Net.Documents.Field}s, even though technically they have {@link Lucene.Net.Documents.Fieldable}s.

Working with Documents

First and foremost, a {@link Lucene.Net.Documents.Document} is something created by the user application. It is your job to create Documents based on the content of the files you are working with in your application (Word, txt, PDF, Excel or any other format.) How this is done is completely up to you. That being said, there are many tools available in other projects that can make the process of taking a file and converting it into a Lucene {@link Lucene.Net.Documents.Document}. To see an example of this, take a look at the Lucene demo and the associated source code for extracting content from HTML.

The {@link Lucene.Net.Documents.DateTools} is a utility class to make dates and times searchable (remember, Lucene only searches text). {@link Lucene.Net.Documents.NumericField} is a special helper class to simplify indexing of numeric values (and also dates) for fast range range queries with {@link Lucene.Net.Search.NumericRangeQuery} (using a special sortable string representation of numeric values).

The {@link Lucene.Net.Documents.FieldSelector} class provides a mechanism to tell Lucene how to load Documents from storage. If no FieldSelector is used, all Fieldables on a Document will be loaded. As an example of the FieldSelector usage, consider the common use case of displaying search results on a web page and then having users click through to see the full document. In this scenario, it is often the case that there are many small fields and one or two large fields (containing the contents of the original file). Before the FieldSelector, the full Document had to be loaded, including the large fields, in order to display the results. Now, using the FieldSelector, one can {@link Lucene.Net.Documents.FieldSelectorResult#LAZY_LOAD} the large fields, thus only loading the large fields when a user clicks on the actual link to view the original content.