lucene - Sitecore 7 ContentSearch crawling failure: "Crawler : AddRecursive DoItemAdd failed" -


when try rebuild our lucene (contentsearch) indexes, our crawlinglog filled these exceptions:

7052 15:08:21 warn  crawler : addrecursive doitemadd failed - {5a1e50e4-46b9-42d5-b743-1ed10d15d47e} exception: system.aggregateexception message: 1 or more errors occurred. source: mscorlib    @ system.threading.tasks.task.wait(int32 millisecondstimeout, cancellationtoken cancellationtoken)    @ system.threading.tasks.task.wait()    @ system.threading.tasks.parallel.partitionerforeachworker[tsource,tlocal](partitioner`1 source, paralleloptions paralleloptions, action`1 simplebody, action`2 bodywithstate, action`3 bodywithstateandindex, func`4 bodywithstateandlocal, func`5 bodywitheverything, func`1 localinit, action`1 localfinally)    @ system.threading.tasks.parallel.foreachworker[tsource,tlocal](ienumerable`1 source, paralleloptions paralleloptions, action`1 body, action`2 bodywithstate, action`3 bodywithstateandindex, func`4 bodywithstateandlocal, func`5 bodywitheverything, func`1 localinit, action`1 localfinally)    @ system.threading.tasks.parallel.foreach[tsource](ienumerable`1 source, paralleloptions paralleloptions, action`1 body)    @ sitecore.contentsearch.abstractdocumentbuilder`1.additemfields()    @ sitecore.contentsearch.luceneprovider.crawlerluceneindexoperations.getindexdata(iindexable indexable, iproviderupdatecontext context)    @ sitecore.contentsearch.luceneprovider.crawlerluceneindexoperations.builddatatoindex(iproviderupdatecontext context, iindexable version)    @ sitecore.contentsearch.luceneprovider.crawlerluceneindexoperations.add(iindexable indexable, iproviderupdatecontext context, providerindexconfiguration indexconfiguration)    @ sitecore.contentsearch.sitecoreitemcrawler.doadd(iproviderupdatecontext context, sitecoreindexableitem indexable)    @ sitecore.contentsearch.hierarchicaldatacrawler`1.crawlitem(tuple`3 tuple) nested exception exception: system.argumentoutofrangeexception message: index , length must refer location within string. parameter name: length source: mscorlib    @ system.string.internalsubstringwithchecks(int32 startindex, int32 length, boolean falwayscopy)    @ sitecore.data.shortid.encode(string guid)    @ sitecore.contentsearch.fieldreaders.multilistfieldreader.getfieldvalue(iindexabledatafield indexablefield)    @ sitecore.contentsearch.fieldreaders.fieldreadermap.getfieldvalue(iindexabledatafield field)    @ sitecore.contentsearch.luceneprovider.lucenedocumentbuilder.addfield(iindexabledatafield field)    @ system.threading.tasks.parallel.<>c__displayclass32`2.<partitionerforeachworker>b__30()    @ system.threading.tasks.task.innerinvokewitharg(task childtask)    @ system.threading.tasks.task.<>c__displayclass11.<executeselfreplicating>b__10(object param0) 

this appears caused shortid.encode(string) method expecting guid in string parameter have brackets (" { " , " } ") around it. of our multilist field relationships associated programmatically using guid.tostring(), not include brackets. unfortunately, these values cause shortid.encode() method choke.

  1. first things first: find places call multilistfield.add(string) , change guid.tostring() guid.tostring("b"). resolve issue new relationships.
  2. create custom fieldreader class replace standard multilistfieldreader (we called ours custommultilistfieldreader).
  3. set custom class inherit sitecore.contentsearch.fieldreaders.fieldreader.
  4. decompile sitecore.contentsearch.fieldreaders.multilistfieldreader.getfieldvalue(iindexabledatafield) method custom class.
  5. before if (id.isid(id)) line, add following code:

    if (!str.startswith("{") && !str.endswith("}"))     id = string.format("{{{0}}}", str); 
  6. in index configuration (we added ours default, sitecore.contentsearch.defaultindexconfiguration.config) change fieldreadertype multilist fields custom type. (this can found in config @ sitecore/contentsearch/configuration/defaultindexconfiguration/fieldreaders/mapfieldbytypename/fieldreader.)

full disclosure: don't love approach because if default implementation of multilistfieldreader ever changed, we'd without changes. allows items included in index without reformatting of guids in every multilist field.


Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -