SearchPhaseExecutionException[Failed to execute phase [query]

  • Updated

This articles describes an error that can happen when calling a search. For example when calling:

var query = SearchClient.Instance.Search().FilterForVisitor().HistogramFacetFor(x => x.StartPublish.Value , DateInterval.Year);

the following error would appear.

The remote server returned an error: (400) Bad Request.

SearchPhaseExecutionException[Failed to execute phase [query], all shards failed; shardFailures {[04E6LChKQ0GFPQJBStIZog][armahe_phoenixdevindex][1]: RemoteTransportException[[euw1afinddev01esd06][inet[/10.54.3.206:9300]][search/phase/query]]; nested: SearchParseException[[armahe_phoenixdevindex][1]: query[filtered(ConstantScore(+NotFilter(cache(___types:EPiServer.Core.IContent)) cache(IsDeleted$$bool:F) ++NotFilter(cache(___types:EPiServer.Core.ILocalizable)) +NotFilter

...

$string:PackagingAdmins RolesWithReadAccess$$string:WebAdmins RolesWithReadAccess$$string:WebEditors) +cache(___types:EPiServer.Core.IContent)))->cache(___types:MyProject.Website.Models.INewsRoomContent)],from[0],size[20]: Parse Failure [Failed to parse source [

...

nested: FacetPhaseExecutionException[Facet [StartPublish.Value]: (key) field [StartPublish.Value$$date] not found]; }] ---> System.Net.WebException: The remote server returned an error: (400) Bad Request.

In this example this issue occurs because the StartPublish property was not indexed. The recommendation is to index the property and rerun the search. This can happen on other properties as well.