Find - Error when clicking search result but result loads correctly

Vote:
 

Hi,

We have a search page which uses Find and I am seeing an error when the user clicks a search result but the actual page the result is for loads as expected. 

The search is UnifiedSearch and we loop through the UnifiedResults in the view and use document.Url to show the link to the result. When you hover over the result there are additional paramters appended to the result which I believe are there as we have statistics enabled.

When you click on a result it seems to trigger another search, I assume as a result of the paramters? It's this second search that triggers an error behind the scenes however the page for the search result loads as expected and does not have the additional parameters appended to the Url.

The error that is raised is:

"The extension method 'For' must be called before the query has been otherwise set"

and the stack trace for this is:

System.InvalidOperationException: The extension method 'For' must be called before the query has been otherwise set
at EPiServer.Find.TypeSearchExtensions.<>c__DisplayClass1_0`1.<For>b__0(ISearchContext context)
at EPiServer.Find.Search`2.ApplyActions(ISearchContext searchContext)
at EPiServer.Find.Search`2.ApplyActions(ISearchContext searchContext)
at EPiServer.Find.Search`2.ApplyActions(ISearchContext searchContext)
at EPiServer.Find.Search`2.ApplyActions(ISearchContext searchContext)
at EPiServer.Find.Search`2.ApplyActions(ISearchContext searchContext)
at EPiServer.Find.Search`2.ApplyActions(ISearchContext searchContext)
at EPiServer.Find.Search`2.ApplyActions(ISearchContext searchContext)
at EPiServer.Find.Search`2.ApplyActions(ISearchContext searchContext)
at EPiServer.Find.Search`2.ApplyActions(ISearchContext searchContext)
at EPiServer.Find.Search`2.ApplyActions(ISearchContext searchContext)
at EPiServer.Find.Search`2.ApplyActions(ISearchContext searchContext)
at EPiServer.Find.Search`2.ApplyActions(ISearchContext searchContext)
at EPiServer.Find.Search`2.ApplyActions(ISearchContext searchContext)
at EPiServer.Find.Search`2.ApplyActions(ISearchContext searchContext)
at EPiServer.Find.SearchExtensions.GetResult(ITypeSearch`1 search, HitSpecification hitSpecification, Boolean filterForPublicSearch)

Has anyone encountered this before and know how to prevent an additional search or the error happening?

Thanks,

Mark

#224823
Jun 26, 2020 14:46
Vote:
 

What does the additional parameters look like?

#224826
Jun 26, 2020 16:20
Vote:
 

Hi Tomas,

The result Url has the following parameters added, I've removed the values:

?_t_id=
&_t_q=
&_t_tags=
&_t_ip=
&_t_hit.id=
&_t_hit.pos=

Thinking about it, it would kind of make sense that it does another search if statistics are enabled as I guess it's logging the fact the result has been clicked and the various parameters needed to get the result?

Assuming this is valid how would I prevent the underlying error we see?

Thanks,

Mark

#224934
Jun 30, 2020 7:42
Vote:
 

I think those parameters can be used to highlight the search term on every page in the search result, even after the visitor follows the links to the pages in the search result.

Not sure how to get rid of them, though.

#224936
Jun 30, 2020 8:01
* 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.