![]() A Document is simply a set of named Fields, Provides an abstraction over the encoding and decoding of the inverted index structure,Īs well as different implementations that can be chosen depending upon application needs.Ĭlass. provides a number of Analyzer implementations, including Tokenizers and TokenFilters are strung together and applied with an Analyzer. The Lucene API is divided into several packages:ĪPI for converting text from a Ī TokenStream can be composed by applying TokenFilters ScoreDoc hits = isearcher.Search(query, null, 1000).ScoreDocs ĭocument hitDoc = isearcher.Doc(hits.Doc) Īssert.AreEqual("This is the text to be indexed.", hitDoc.Get("fieldname")) QueryParser parser = new QueryParser(LuceneVersion.LUCENE_CURRENT, "fieldname", analyzer) Parse a simple query that searches for "text": IndexSearcher isearcher = new IndexSearcher(ireader) Using DirectoryReader ireader = DirectoryReader.Open(directory) String text = "This is the text to be indexed." ĭoc.Add(new Field("fieldname", text, TextField.TYPE_STORED)) Using IndexWriter iwriter = new IndexWriter(directory, config) IndexWriterConfig config = new IndexWriterConfig(LuceneVersion.LUCENE_CURRENT, analyzer) Directory directory = FSDirectory.Open(indexPath) var indexPath = Path.Combine(basePath, "index") var basePath = Environment.GetFolderPath() Construct a machine-independent path for the index ![]() To store an index on disk, use this instead: Here's a simple example how to use Lucene.NET for indexing and searching (using NUnit to check if the results are what we expect): Analyzer analyzer = new StandardAnalyzer(Version.LUCENE_CURRENT) ĭirectory directory = new RAMDirectory() Apache Lucene.NET is a high-performance, full-featured text search engine library. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |