开发者

hibernate search multiple fields based on language

开发者 https://www.devze.com 2023-02-21 19:00 出处:网络
I\'m interested in changing db full text search to lucene. I\'m using hibernate so I guess it would be smart to use hibernate search. I have a problem though.

I'm interested in changing db full text search to 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开发者_StackOverflow中文版 know how well it would work with current transactions. 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:

public String getEnghlishTitle(){...}

public String 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. 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.

0

精彩评论

暂无评论...
验证码 换一张
取 消