简体   繁体   English

如何使用Hibernate Search / Lucene索引取决于列值的行?

[英]How to index rows dependent on column values with Hibernate Search / Lucene?

Is it possible to use hibernate search/lucene to index some entity based on values of some fields? 是否可以使用休眠搜索/ lucene根据某些字段的值来索引某些实体?

For example, let's take the following example: A product has several properties with values. 例如,让我们以以下示例为例:一个产品具有多个带有值的属性。 eg property names could be color, amount, order-date, price, whatever... 例如,属性名称可以是颜色,数量,订购日期,价格等等。

PRODUCT (
   name
   description
   ...
)

PROPERTY (
    id
    name
    value
    fk_product
 )

And I only want to index PRODUCTS that have a property COLOR, but I never want to search on property SIZE. 而且我只想索引具有属性COLOR的PRODUCTS,但我永远不想搜索属性SIZE。

Also, Is it possible to index my products with hibernate search and be able to query only on specific property names (like they where fields on a project)? 另外,是否可以通过休眠搜索为我的产品建立索引,并且仅能够查询特定的属性名称(例如它们在项目中的字段中)?

Some query like this: color:blue that would return me all products that have a property name=color with the value=blue. 像这样的一些查询: color:blue ,它将向我返回所有具有name = color属性且value = blue的产品。

From the reference doc I don't find anything, but maybe should I use Filters to restrict the querying depending on the values of some fields! 从参考文档中我什么都找不到,但是也许我应该根据某些字段的值使用过滤器来限制查询!

After rereading the reference documentation I realized I had to use a ClassBridge . 重新阅读参考文档后,我意识到必须使用ClassBridge (section 4.2.2.3 in the documentation) This solves exactly my problem! (文档中的4.2.2.3节)这完全解决了我的问题!

The example of the documentation is straight forward. 该文档的示例很简单。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM