I have a block (VideoBlock) that has a string type named Video (represents video id). I had to prevent users from creating more than one video block with same video id and used below code in Save event.
if (args.Content is VideoBlock videoBlock)
{
var videoList = _client.Search<VideoBlock>()
.Filter(x => x.Video.Match(videoBlock.Video))
.GetContentResult();
if (videoList.TotalMatching == 0) { return; }
if (videoList.TotalMatching == 1)
{
if (((IContent)videoList.First()).ContentLink.CompareToIgnoreWorkID(((IContent)videoBlock).ContentLink))
{
return;
}
}
args.CancelAction = true;
args.CancelReason = "Video Block already exists";
}
This was working all fine till recently. Now when user tries to create a video block and puts existing Video id, the screen freezes and I don't see anything in the logs. I tried to copy paste an existing block and found below error:
Failed to copy page 'Test Video' to 'Videos'.:Exception: The remote server returned an error: (400) Bad Request. SearchPhaseExecutionException[Failed to execute phase [query], all shards failed; shardFailures.