Lucene是否支持在多个索引文档之间进行搜索? [英] Does Lucene support searching between multiple index documents?

查看:92
本文介绍了Lucene是否支持在多个索引文档之间进行搜索?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在数据库中:

我有两个桌子.每个表中有三列. 表格A(column_primaryKey_A,column_A1,column_A2) Table_B(column_primaryKey_B,column_B1,column_B2)

I have two tables. and there are three columns in each table. Table_A (column_primaryKey_A,column_A1,column_A2) Table_B (column_primaryKey_B,column_B1,column_B2)

下面是我要使用Lucene进行的SQL: SELECT * FROM Table_A,Table_B WHERE column_primaryKey_A = column_primaryKey_B AND AND_strong> column_A1 = XX AND column_B1 = XX

Below is the SQL that I want to do using Lucene: SELECT * FROM Table_A,Table_B WHERE column_primaryKey_A = column_primaryKey_B AND column_A1 = XX AND column_B1 = XX

我要创建两个索引文档( Index_Table_A Index_Table_A ),并且如何使用Lucene或Hibernate Search机制实现上述功能?.

I want to create two index documents(Index_Table_A, Index_Table_A)and how do I implement above things using the mechanism of Lucene or Hibernate Search?.

任何帮助都会令人感激!

Any help will be thankful!

推荐答案

我不确定您为什么需要索引或为什么首先要使用lucene,但是我可以告诉您如何实现它使用一个索引. (可以使用两个索引,但性能明显降低)

I'm not sure why do you need to indexes or why do you want to use lucene in the first place, but I can tell you how to implement it using one index. (using two indexes is possible but is significantly less performance)

使用一个索引,对任何文档进行索引,如下所示:

Using one index, index any document as following:

title = column_primaryKey_A
column_A1 = val...
column_A2 = val2...
column_B1 = val3...
column_B2 = val4...

搜索时,您希望对字段查询使用以下条件的联合查询

When searching you would like to use a conjuntion query on field queries as following

query = (column_A1:XX) AND (column_B1:XX)

您可以在此处上找到有关Lucene查询语法的更多信息.

You could find more information here on lucene query syntax.

编辑:另一种由两次搜索组成的选项可能效果不佳: 您可以在第一列上进行第一次搜索,以收集所有相应的标题(id),然后将它们添加到第二个查询中(在第二列上):

Another option consist of two searches might be less performing: You could have a first search on the first column collecting all the corresponding titles (id's), and add them to a second query (on the second column):

Query: (Column_B1:XX) AND ( id1 OR id2 OR ...)

其中的ID是从第一次搜索中收集的结果.

where the Id's are the results collected from the first search.

这篇关于Lucene是否支持在多个索引文档之间进行搜索?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆