SolrServer: is schema required when using addBean(

2019-07-25 07:26发布

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)

标签: solr solrj
1条回答
贼婆χ
2楼-- · 2019-07-25 08:13

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

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
查看更多
登录 后发表回答