Linq to Lucene:“Lucene Term的谓词不能是空字符串。”

时间:2022-04-28 03:07:48

I am trying to implement Linq To Lucene in my project, but when trying to search for something, I am always getting a Enumeration yielded no results result and when I debug and try to open my [IndexContext].[TableProperty] in the Watch window, I am getting this message:

我正在尝试在我的项目中实现Linq To Lucene,但是当我尝试搜索某些内容时,我总是得到一个Enumeration没有产生结果,当我调试并尝试打开我的[IndexContext]。[WatchProperty]在Watch窗口中,我收到这条消息:

The predicate of a Lucene Term can not be the empty string.

Lucene Term的谓词不能是空字符串。

I have tried searching in Google for this, but apparently it returned no results!

我曾尝试在Google上搜索此内容,但显然它没有返回任何结果!

Has anyone ever encountered this message before? And how can I fix it? because currently it's not returning any data

有没有人曾经遇到过这个消息?我该如何解决?因为目前它没有返回任何数据

[Update]

Apparently the problem is when I am using one of the Extension Methods (Between, Match, Like etc...) that are found in Lucine.Linq.Extensions. Take the following example:

显然问题是当我使用Lucine.Linq.Extensions中的一个扩展方法(Between,Match,Like等...)时。采用以下示例:

var db = new MusicRepo_DB_IndexContext(@"C:\MusicRepoDB_index",
                                       new MusicRepo_DBDataContext());

The following query returns a result: db.Artists.Where(a => a.Name == "Camel");

以下查询返回结果:db.Artists.Where(a => a.Name ==“Camel”);

But this one doesn't: db.Artists.Where(a => a.Search("Camel"));

但是这个不是:db.Artists.Where(a => a.Search(“Camel”));

[Update]

Upon further testing, I realized that the Match extension method does actually return a result, wheres as the other ones (Search, Like) don't. I'm still struggling with this issue

经过进一步的测试,我意识到Match扩展方法确实会返回一个结果,因为其他的(Search,Like)没有。我还在努力解决这个问题

1 个解决方案

#1


I am using it in my project too and my belief is that this message shows up “The predicate of a Lucene Term can not be the empty string.”, because Lucene does not accept an empty term as a search criteria.

我也在我的项目中使用它,我的信念是这条消息显示“Lucene Term的谓词不能是空字符串。”,因为Lucene不接受空术语作为搜索条件。

That's what happened to me:

这就是发生在我身上的事情:

(Northwind database) When I tried to search

(罗斯文数据库)当我试图搜索

var mmCustomers = from c in dbi.Get<Customer>()
                      where c.ContactTitle == "Marketing Manager"                       
                      select c;

it works fine, but when I try:

它工作正常,但当我尝试:

var mmCustomers = from c in dbi.Get<Customer>()                       
                      select c;

it shows the “The predicate of a Lucene Term can not be the empty string.” error.

它显示“Lucene术语的谓词不能是空字符串。”错误。

Hope it helps

希望能帮助到你

#1


I am using it in my project too and my belief is that this message shows up “The predicate of a Lucene Term can not be the empty string.”, because Lucene does not accept an empty term as a search criteria.

我也在我的项目中使用它,我的信念是这条消息显示“Lucene Term的谓词不能是空字符串。”,因为Lucene不接受空术语作为搜索条件。

That's what happened to me:

这就是发生在我身上的事情:

(Northwind database) When I tried to search

(罗斯文数据库)当我试图搜索

var mmCustomers = from c in dbi.Get<Customer>()
                      where c.ContactTitle == "Marketing Manager"                       
                      select c;

it works fine, but when I try:

它工作正常,但当我尝试:

var mmCustomers = from c in dbi.Get<Customer>()                       
                      select c;

it shows the “The predicate of a Lucene Term can not be the empty string.” error.

它显示“Lucene术语的谓词不能是空字符串。”错误。

Hope it helps

希望能帮助到你