搜索两个字段匹配的记录

时间:2014-09-17 07:35:32

标签: java lucene

我有一个包含这些字段的索引(post.id,topic.id,contents)。

我想搜索记录,其中" post.id = topic.id"。

我试过

+(post.id:topic.id)

但我没有运气。

我对Lucene来说还不够新鲜。

我生成的查询如下所示。

+(forum.id:9)  +(contents:test*)  +(post.id:topic.id)

我认为它应该向我提取任何包含test * in contents的记录,其中post.id与topic.id相同但它没有按照我的预期工作。

我可能会把这一切都搞错了。

我做错了什么?

1 个答案:

答案 0 :(得分:0)

我不知道有任何方法可以直接做到这一点。但解决方法是使用Lucene连接功能(索引或查询时间连接)。请查看here以了解如何使用它。

在Solr中,你可以做这样的事情

http://127.0.0.1:8983/solr/collection1/select/?q={!join from=post.id to=topic.id} content:test
相关问题