简体   繁体   English

如何在Solr Index中添加Java entites?

[英]How to add java entites to Solr Index?

I'm new to solr. 我是新来的。 I've gone through a couple of blogs on solr integration into a web project. 我浏览了一些关于Solr集成到Web项目中的博客。 In my current project, the different java entities are stored in the solr index as space separated serialized string. 在我当前的项目中,不同的Java实体作为空格分隔的序列化字符串存储在solr索引中。 Like, firstname + " " + lastname + " " + email....and so on. 例如,名字+“” +姓氏+“” +电子邮件...等等。 All the disparate entities are stored like this with classname_primaryId as the unique key. 像这样存储所有不同的实体,并将classname_primaryId作为唯一键。 Is this the standard way of storing the different entities in solr? 这是在Solr中存储不同实体的标准方法吗? How should I go about it? 我应该怎么做? Can I keep these entities separately in solr? 我可以将这些实体单独放在Solr中吗? Any guidance/help is appreciated. 任何指导/帮助表示赞赏。 I'm already short on time!!!! 我已经没时间了!!!

Solr is a document search engine, so you should think about your data in those terms. Solr是一个文档搜索引擎,因此您应该以这些术语考虑数据。

If you want to make the entities searchable, I believe that the best way would be to serialize the Java entities into documents (objects represented in JSON), and then add specialized fields (such as a copyField that contains data from all other fields that you want to search when field name is not specified) on top of that. 如果您想使实体可搜索,我认为最好的方法是将Java实体序列化为文档(以JSON表示的对象),然后添加专门的字段(例如copyField,其中包含您所有其他字段的数据)要在未指定字段名称时进行搜索)。 You don't need to do the space separated representation at your application side, Solr handles that automatically when you use a copyField in the schema. 您不需要在应用程序端进行空格分隔的表示,当您在模式中使用copyField时,Solr会自动处理。

In this way you have the ability to search on per field basis, and when required search on all fields at once by targetting the copy field. 这样,您就可以在每个字段中进行搜索,并在需要时通过定位复制字段来一次在所有字段中进行搜索。

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

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