如何使用 Hibernate Search / Lucene 根据列值对行进行索引?

发布于 2024-08-16 12:01:54 字数 468 浏览 4 评论 0原文

是否可以使用 hibernate search/lucene 根据某些字段的值来索引某些实体?

例如,让我们看下面的例子:一个产品有多个带有值的属性。 例如,属性名称可以是颜色、金额、订单日期、价格等等...

PRODUCT (
   name
   description
   ...
)

PROPERTY (
    id
    name
    value
    fk_product
 )

我只想索引具有属性 COLOR 的产品,但我不想搜索属性 SIZE。

另外,是否可以使用休眠搜索对我的产品进行索引,并且只能查询特定的属性名称(例如项目中的字段)?

像这样的一些查询:color:blue 会返回所有具有属性 name=color 且 value=blue 的产品。

从参考文档中我没有找到任何内容,但也许我应该使用过滤器根据某些字段的值来限制查询!

Is it possible to use hibernate search/lucene to index some entity based on values of some fields?

For example, let's take the following example: A product has several properties with values.
e.g. 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.

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.

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!

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

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

发布评论

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

评论(1

樱花细雨 2024-08-23 12:01:55

重新阅读参考文档后,我意识到我必须使用 ClassBridge 。 (文档中的第 4.2.2.3 节)这完全解决了我的问题!

文档的示例很简单。

After rereading the reference documentation I realized I had to use a ClassBridge. (section 4.2.2.3 in the documentation) This solves exactly my problem!

The example of the documentation is straight forward.

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