Solr 4.2 - what is _version_field?
Asked Answered
M

3

17

I am getting below error in my solr configuration.

Caused by: org.apache.solr.common.SolrException: Unable to use updateLog: _version_field must exist in schema, using indexed="true" stored="true" and multiValued="false" (_version_ does not exist)
        at org.apache.solr.core.SolrCore.<init>(SolrCore.java:806)
        at org.apache.solr.core.SolrCore.<init>(SolrCore.java:619)
        at org.apache.solr.core.CoreContainer.createFromLocal(CoreContainer.java:1021)
        at org.apache.solr.core.CoreContainer.create(CoreContainer.java:1051)
        ... 10 more
Caused by: org.apache.solr.common.SolrException: Unable to use updateLog: _version_field must exist in schema, using indexed="true" stored="true" and multiValued="false" (_version_ does not exist)
        at org.apache.solr.update.UpdateLog.init(UpdateLog.java:245)
        at org.apache.solr.update.UpdateHandler.initLog(UpdateHandler.java:84)
        at org.apache.solr.update.UpdateHandler.<init>(UpdateHandler.java:134)
        at org.apache.solr.update.DirectUpdateHandler2.<init>(DirectUpdateHandler2.java:95)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:532)
        at org.apache.solr.core.SolrCore.createInstance(SolrCore.java:526)
        at org.apache.solr.core.SolrCore.createUpdateHandler(SolrCore.java:597)
        at org.apache.solr.core.SolrCore.<init>(SolrCore.java:790)
        ... 13 more
Caused by: org.apache.solr.common.SolrException: _version_field must exist in schema, using indexed="true" stored="true" and multiValued="false" (_version_ does not exist)
        at org.apache.solr.update.VersionInfo.getAndCheckVersionField(VersionInfo.java:57)
        at org.apache.solr.update.VersionInfo.<init>(VersionInfo.java:83)
        at org.apache.solr.update.UpdateLog.init(UpdateLog.java:242)
        ... 23 more

I wanted to know that what is _version_field, and why its must required ?

Can anybody suggest me on this??

Microscopium answered 20/3, 2013 at 15:8 Comment(0)
R
21

The _version_ field is an internal field that is used by the partial update procedure, the update log process, and by SolrCloud. It is only used internally for those processes, and simply providing the _version_ field in your schema.xml should be sufficient.

If you'd like information as to exactly what is going on with _version_, you can visit this website to learn about the "optimistic concurrency" update process, which uses _version_.

Rutkowski answered 22/3, 2013 at 23:11 Comment(3)
Does adding this field into the Schema has any impact on the index size?Contracted
@Krunal: what do you think will happen on adding an extra attribute to each document?Cavill
@ashish, we tested this to understand the impact on index size and performance. We found no significant change in index size nor performance. So we decided to left the field into our schema for making it support partial update in future.Contracted
C
29

add the below field definition inside "field" tag in schema.xml

<field name="_version_" type="long" indexed="true" stored="true" multiValued="false"/>
Cavill answered 18/7, 2013 at 12:51 Comment(4)
I think you mean typr="slong". long oesn't appear to work on Solr 4.4.Jarred
actually there was no need to define version field earlier, it is mandatory when solr added feature to update document partiallyCavill
@SalvatoreIovene with 4.10, 'slong' didn't work, but 'long' did.Synopsis
If you need to use slong or long depends on type definitions inside the <types> element.Monsour
R
21

The _version_ field is an internal field that is used by the partial update procedure, the update log process, and by SolrCloud. It is only used internally for those processes, and simply providing the _version_ field in your schema.xml should be sufficient.

If you'd like information as to exactly what is going on with _version_, you can visit this website to learn about the "optimistic concurrency" update process, which uses _version_.

Rutkowski answered 22/3, 2013 at 23:11 Comment(3)
Does adding this field into the Schema has any impact on the index size?Contracted
@Krunal: what do you think will happen on adding an extra attribute to each document?Cavill
@ashish, we tested this to understand the impact on index size and performance. We found no significant change in index size nor performance. So we decided to left the field into our schema for making it support partial update in future.Contracted
G
1

If you remove it, you must also remove the transaction logging from solrconfig.xml. See the link.

Grochow answered 22/7, 2014 at 9:17 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.