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

发布于 2024-07-18 05:23:25 字数 982 浏览 7 评论 0原文

我正在尝试在我的项目中实现 Linq To Lucene,但是当尝试搜索某些内容时,我总是得到 Enumeration returns no results 结果,当我调试并尝试打开我的 [ IndexContext].[TableProperty]Watch 窗口中,我收到以下消息:

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

我尝试在谷歌中搜索这个,但显然没有返回任何结果!

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

[更新]

显然问题是当我使用扩展方法之一时(BetweenMatch、< code>Like 等...),可在 Lucine.Linq.Extensions 中找到。 举个例子:

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

下面的查询返回一个结果:db.Artists.Where(a => a.Name == "Camel");

但这个查询却没有:db .Artists.Where(a => a.Search("Camel"));

[更新]

经过进一步测试,我意识到 Match 扩展方法实际上会返回结果,而其他方法(SearchLike)则不会。 我还在为这个问题苦苦挣扎

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:

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

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

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:

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");

But this one doesn't: 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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

海夕 2024-07-25 05:23:25

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

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

(Northwind 数据库)
当我尝试搜索时,

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

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

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

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

希望能帮助到你

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.

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.

Hope it helps

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文