That's a really odd error message to be getting. It appears to be saying that the system can't locate generic List type. In .Net 5 this type is stored here:
region Assembly System.Collections, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
// C:Program FilesdotnetpacksMicrosoft.NETCore.App.Ref5.0.0
ef
et5.0System.Collections.dll
While you are seeing the error because StandardAnalyzer uses this type and the system can't locate it, it's quite possible that the issue has nothing to do with Lucene.Net per se. You can test that theory by trying to do the following:
List<string> list = new List<string>();
list.Add("hello world");
There is a very good change that code will blow up the same way. If so then the issue isn't related to Lucene.
What I can say for sure is that Lucene. 4.8 Beta, is extremely feature complete, very stable and the StandardAnalyzer
works great on my system using .Net 5.0. I happen to be using Lucene.Net 4.8.0-beta00013 currently with .Net 5 but I've been using Lucene.Net with other version of .Net Core since Lucene.Net version 4.8.0-beta0006, and my personal experience is that it's an amazing search library.
To test out the Lucene.Net StandardAnalyzer on .Net 5.0 for you I created the unit test below in xUnit. The unit test passes and demonstrates that StandardAnalyzer
is working. This code could probably be simplified a bit since it uses an approach that provides a Near Real Time reader but it will give you a meaty sample to work with once you resolve why your system can't find the generic List class.
[Fact]
public void TestStandardAnalyzer() {
Directory indexDir = new RAMDirectory();
Analyzer standardAnalyzer = new StandardAnalyzer(LuceneVersion.LUCENE_48);
IndexWriterConfig indexConfig = new IndexWriterConfig(LuceneVersion.LUCENE_48, standardAnalyzer);
indexConfig.UseCompoundFile = true;
IndexWriter writer = new IndexWriter(indexDir, indexConfig);
//souce: https://github.com/apache/lucenenet/blob/Lucene.Net_4_8_0_beta00006/src/Lucene.Net/Search/SearcherFactory.cs
SearcherManager searcherManager = new SearcherManager(writer, applyAllDeletes: true, new SearchWarmer());
Document doc = new Document();
doc.Add(new StringField("examplePrimaryKey", "001", Field.Store.YES));
doc.Add(new TextField("exampleField", "Unique gifts are great gifts.", Field.Store.YES));
writer.AddDocument(doc);
doc = new Document();
doc.Add(new StringField("examplePrimaryKey", "002", Field.Store.YES));
doc.Add(new TextField("exampleField", "Everyone is gifted.", Field.Store.YES));
writer.AddDocument(doc);
doc = new Document();
doc.Add(new StringField("examplePrimaryKey", "003", Field.Store.YES));
doc.Add(new TextField("exampleField", "Gifts are meant to be shared.", Field.Store.YES));
writer.AddDocument(doc);
writer.Commit();
searcherManager.MaybeRefreshBlocking();
IndexSearcher indexSearcher = searcherManager.Acquire();
try {
QueryParser parser = new QueryParser(LuceneVersion.LUCENE_48, "exampleField", standardAnalyzer);
Query query = parser.Parse("everyone");
TopDocs topDocs = indexSearcher.Search(query, int.MaxValue);
int numMatchingDocs = topDocs.ScoreDocs.Length;
Assert.Equal(1, numMatchingDocs);
Document docRead = indexSearcher.Doc(topDocs.ScoreDocs[0].Doc);
string primaryKey = docRead.Get("examplePrimaryKey");
Assert.Equal("002", primaryKey);
} finally {
searcherManager.Release(indexSearcher);
}
}