1

I have this situation

Entity Company_id 
-----------------
E001     1        
E001     2       
E003     1
E002     2
E001     3
E003     3

I want to know how much companies that have entities (E001 and E003) in this case the result should be company 1 and 3.

In SQL it can be resolved by making a nested query but I should use something like luncene because of performance needs this query will be executed more that 50 times for each page.

Note : I can have to restrict on 3 or 4 entities also ex : all companies that have (E001 AND E002 AND E003 AND 3004).

Any help will be appreciated

EDIT I know that lucene is made for text search but let's suppose that each row is a Document in the index.

4

1 回答 1

0

如果您可以配置您的 Lucene 索引,以便每个公司都是一个 Lucene 文档并且它们包含 0 个或多个实体,那么(在查询解析器语法中)“所有具有 E001 AND E003 的公司”变为:

+entity:E001 +entity:E003

(其中entity是实体字段)。“所有具有 E001 AND E002 AND E003 AND E004 的公司变为:

+实体:E001 +实体:E002 +实体:E003 +实体:E004

然后只需将“Company_id”作为公司文档的存储字段包含在内,这样您就可以在查询结果中看到它。

于 2013-08-16T18:30:32.773 回答