Don't miss out Virtual Happy Hour this Friday (April 26).

Try our conversational search powered by Generative AI!

Index was out of range in HitSpecification

Vote:
 

Hi,

Sometimes we get an error in HitSpecification. I guess it's related to ExcerptLength. This is our code:

query.GetResult(
    new HitSpecification
    {
        HighlightTitle = true,
        HighlightExcerpt = true,
        ExcerptLength = 400,
        PreTagForAllHighlights = "<strong>",
        PostTagForAllHighlights = "</strong>",
    });

And this is the error message:

[ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: startIndex]
   System.String.IndexOf(String value, Int32 startIndex, Int32 count, StringComparison comparisonType) +10675470
   EPiServer.Find.Helpers.Text.StringExtensions.TruncateWholeWords(String value, Int32 maxLength) +90
   EPiServer.Find.Helpers.Text.StringExtensions.AddFallbackToBeginningOfHighlightedText(String highlightedText, String fallbackText, Int32 maxLength, Int32 numberOfWordsToCompareForSameTextCheck, String separator) +426
   EPiServer.Find.UnifiedSearch.HitProjectionBuilder.PadBeginning(String originalText, String fallbackText, Int32 maxLength) +17
   lambda_method(Closure ) +400

[TargetInvocationException: Exception has been thrown by the target of an invocation.]
   System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor) +0
   System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments) +192
   System.Delegate.DynamicInvokeImpl(Object[] args) +117
   EPiServer.Find.ProjectionHelper.GetMappedSearchResultItem(SearchRequestBody requestBody, SearchHit`1 searchHit) +357
   EPiServer.Find.ProjectionHelper.GetMappedResult(SearchRequestBody requestBody, SearchResults`1 jsonResult) +556
   EPiServer.Find.SearchExtensions.GetProjectedResult(ISearch`1 search, SearchContext context) +415
   EPiServer.Find.SearchExtensions.GetResult(ITypeSearch`1 search, HitSpecification hitSpecification, Boolean filterForPublicSearch) +1150
#65815
Feb 11, 2013 13:53
Vote:
 

Hi,

I have reported this as a bug that we will kill as soon as possible on our bug bashes. Changing the ExcerptLength might save you as you might have noticed but it is not a solution to the problem as it in the relation between the ExcerptLength and the highlighting falback text length that gets you there.

Regards,

Henrik

#65986
Feb 18, 2013 8:52
Vote:
 

Thanks! When is next release scheduled?

#66048
Feb 18, 2013 23:53
Vote:
 

Not answering when the next release is (I leave that to the EPi folks) but, as a workaround you can swap out the default projection for Excerpt. For Excerpt the default is quite advanced so I'm not saying that you necessarily want to do that, but just highlighting that it's possible :)

#66067
Feb 19, 2013 13:43
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.