• Not Answered

Exception when rebuilding index: missing required field: _id

Hi,

I'm in the process of updating our site from Sitecore 7.0 to 8.1. We use Solr for search, and it worked fine in Sitecore 7.0.

After the laborious process of upgrading the site from Sitecore 7.0 to 8.1, the site almost completely works except when I try to rebuild the search index. I get the exception the following exception (xml tags removed):

Job started: Index_Update_IndexName=forcenet_index|#Exception: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> SolrNet.Exceptions.SolrConnectionException: 
[doc=sitecore://web/{b58d6480-6913-4ef6-b070-a0c96db9a15c} missing required field: _id

That is a sitecore item, that apparently doesn't feed the _id field to Solr, except as can be seen, the item itself has a Guid, I'm not sure what to make of this.

Thanks

3 Replies

  • Can you check if you have in your schema.xml next field ?

    <field name="_id" type="string" indexed="true" stored="true" required="true" />
  • In reply to Sitecore Climber:

    Unfortunately yes, it's the first field directly under the <fields> tag:

    <fields>
    <field name="_id" type="string" indexed="true" stored="true" required="true" />
    ...

    We are using Solr 4.4.0. I tried using Solr 5.3.1 I still get the issues.

    The following message is an example of what happens in the Solr log:

    [doc=sitecore://master/{f9b6d59d-e1d7-48d5-8682-5ce2deb99ce5}?lang=en&ver=1&ndx=sitecore_master_index] missing required field: _id



    Doing a search in the content editor, that item is apparently:

    /sitecore/system/Settings/Rules/Definitions/Obsolete/Marketing Workflows/Conditions/Geo IP/DNS Condition

    Here's the full stack trace when rebuilding the index:

    Job started: Index_Update_IndexName=sitecore_master_index|#Exception: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> SolrNet.Exceptions.SolrConnectionException: <?xml version="1.0" encoding="UTF-8"?>
    <response>
    <lst name="responseHeader"><int name="status">400</int><int name="QTime">2</int></lst><lst name="error"><str name="msg">[doc=sitecore://master/{1256af9c-b1d8-4e1b-bdeb-2e2a4959b0c9}?lang=en&amp;ver=1&amp;ndx=sitecore_master_index] missing required field: _id</str><int name="code">400</int></lst>
    </response>
     ---> System.Net.WebException: The remote server returned an error: (400) Bad Request.
       at System.Net.HttpWebRequest.GetResponse()
       at HttpWebAdapters.Adapters.HttpWebRequestAdapter.GetResponse()
       at SolrNet.Impl.SolrConnection.GetResponse(IHttpWebRequest request)
       at SolrNet.Impl.SolrConnection.PostStream(String relativeUrl, String contentType, Stream content, IEnumerable`1 parameters)
       --- End of inner exception stack trace ---
       at SolrNet.Impl.SolrConnection.PostStream(String relativeUrl, String contentType, Stream content, IEnumerable`1 parameters)
       at SolrNet.Impl.SolrConnection.Post(String relativeUrl, String s)
       at SolrNet.Impl.SolrBasicServer`1.SendAndParseHeader(ISolrCommand cmd)
       at Sitecore.ContentSearch.SolrProvider.SolrBatchUpdateContext.AddRange(IEnumerable`1 group, Int32 groupSize)
       at Sitecore.ContentSearch.SolrProvider.SolrBatchUpdateContext.Commit()
       at Sitecore.ContentSearch.SolrProvider.SolrSearchIndex.PerformRebuild(Boolean resetIndex, Boolean optimizeOnComplete, IndexingOptions indexingOptions, CancellationToken cancellationToken)
       at Sitecore.ContentSearch.SolrProvider.SolrSearchIndex.Rebuild(Boolean resetIndex, Boolean optimizeOnComplete)
       --- End of inner exception stack trace ---
       at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
       at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
       at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
       at Sitecore.Reflection.ReflectionUtil.InvokeMethod(MethodInfo method, Object[] parameters, Object obj)
       at Sitecore.Jobs.JobRunner.RunMethod(JobArgs args)
       at (Object , Object[] )
       at Sitecore.Pipelines.CorePipeline.Run(PipelineArgs args)
       at Sitecore.Jobs.Job.ThreadEntry(Object state)
  • I was getting same issue "missing required field: _datasource" while rebuilding master index for Sitecore 9.0.2 installation. The field was already present in the managed schema file. From Sitecore control panel, I clicked "Populate Solr Managed Schema" and populated the schema for index again. Though I verified that populating schema again did not make any changes to managed schema file, rebuilding succeeded without any issues.