简体   繁体   English

休眠根据语言搜索多个字段

[英]hibernate search multiple fields based on language

I'm interested in changing db full text search to lucene. 我有兴趣将db全文搜索更改为lucene。 I'm using hibernate so I guess it would be smart to use hibernate search. 我正在使用休眠,所以我想使用休眠搜索会很聪明。 I have a problem though. 我有一个问题。

Our record has a list of informations and titles from different languages and I need to be able to search based on a single language and over all languages. 我们的记录包含来自不同语言的信息和标题的列表,我需要能够基于一种语言和所有语言进行搜索。

I could probably do it in plain lucene but I don't know how well it would work with current transactions. 我可能可以使用简单的Lucene来做,但是我不知道它在当前交易中的效果如何。 So using hibernate search and hibernate to deal with the index would be much better. 因此,使用休眠搜索和休眠处理索引会更好。

Is it possible to create such fields in the index to search the way I described? 是否可以在索引中创建此类字段以搜索我描述的方式?

class Record{
    List<Info> infos;
}

class Info{
    String title;
    String infoText;
    String langCode;
}

Can I do it like this. 我可以这样吗 Create getters in Record like this: 在Record中创建吸气剂,如下所示:

public String getEnghlishTitle(){...} 公共字符串getEnghlishTitle(){...}

public String getFullInfos(){...} 公共字符串getFullInfos(){...}

And then put index annotations on these getters and then have necessary fields in index? 然后在这些获取器上放置索引注释,然后在索引中包含必要的字段?

I would write a custom FieldBridge for the infos property. 我将为infos属性编写一个自定义FieldBridge。 Then you have full control which fields you add to the index, eg you could could use text. 然后,您可以完全控制将哪些字段添加到索引,例如可以使用文本。 as field names. 作为字段名称。 This should allow to dynamically decide which language to search for. 这应该允许动态决定要搜索的语言。 Remember you have to think about the analyzers too. 记住,您也必须考虑分析仪。 A custom per field analyzer would work. 一个自定义的每个现场分析仪将起作用。

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

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