SolrServer: is schema required when using addBean( Object bean )?

核能气质少年 提交于 2019-12-11 13:51:53

问题


I saw two methods in SolrServer: addBean( Object bean ) and add (SolrDocument doc ).

My question is:

If I can add objects directly using addBean(), do I need to create any schema for the object? Doesn't Solr look at fields of the object and determine the schema from there?

Or does Solr serialize the object into a string first and then proceeds with a normal add? (This might require schema specification)


回答1:


Solr supports a Schemaless Mode. When starting Solr this way, you are initially not bound to a schema. When you give Solr a first document it will guess the appropriate field types and generate a schema that includes those field types for you. These fields are then fixed. You may still add new fields on the fly that way.

This feature is - imho - good for prototyping and to get first version of a schema, but you should not go to production with such a core.

There are some resources out there giving more details on that topic

  • https://cwiki.apache.org/confluence/display/solr/Schemaless+Mode
  • http://searchhub.org/2013/05/21/schemaless-solr-part-1/

But to answer your question

  1. if you run your server in that schemaless mode, no, you do not need a schema.
  2. if you do not - which is likely, as it does not come out of the box - yes you do need a schema


来源:https://stackoverflow.com/questions/19691549/solrserver-is-schema-required-when-using-addbean-object-bean

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!