public Guid IndexTest(Indexer indexer, string path, string contains) { contains = contains.ToLower(); var file = ReadFile(path); var doc = indexer.CreateDocument(file.Item2); doc.Add(new Field("Id", file.Item1.ToString(), Field.Store.YES, Field.Index.NOT_ANALYZED)); indexer.Writer.AddDocument(doc); indexer.Writer.Commit(); indexer.Refresh(); var parser = new QueryParser(indexer.Version, indexer.DocumentContentField, indexer.Analyser); var query = parser.Parse(contains); var topDocs = indexer.Searcher.Search(query, 1000); //topDocs = indexer.Searcher.Search(query, topDocs.totalHits); var docs = topDocs #if LuceneV290 .scoreDocs .Select(sd => indexer.Searcher.Doc(sd.doc)) #else .ScoreDocs .Select(sd => indexer.Searcher.Doc(sd.Doc)) #endif .ToArray(); Assert.IsTrue(docs.Any(d => d.GetField("Id").AsString() == file.Item1.ToString())); return file.Item1; }