I have simple search page using the following code straight off our Umbraco Examine quick start guide Umbraco Examine quick start guide
if(ExamineManager.Instance.TryGetIndex("ExternalIndex", out var index))
{
var searcher = index.GetSearcher();
var results = searcher.CreateQuery("content").Field("nodeName", searchTerm).Execute();
if (results.Any())
{
<ul>
@foreach (var result in results)
{
if (result.Id != null)
{
var node = Umbraco.Content(result.Id);
<li>
<a href="@node.Url">@node.Name</a>
</li>
}
}
</ul>
}
my view
foreach (var searchResult in @Model.SearchItems.Skip((page - 1) * Model.PageLimit).Take(Model.PageLimit))
{
var searchItem = Umbraco.Content(@searchResult.Id);
<a href="@searchItem.Url()">
<h2>@searchItem.Name</h2>
</a>
if (@searchItem.HasProperty("contentRTE"))
{
@Html.Truncate(@searchItem.Value("contentRTE").ToString(), 250)
}
}
I get back results as expected. Issue arises when content editor unpublishes a parent/ancestor node, this leads to a YSOD when the search results contain a published node under the unpublished node.
Object reference not set to an instance of an object. on line
var searchItem = Umbraco.Content(@searchResultId);
I'm using Umbraco 8 External Index making use of default standardanalyzer. Im not sure how to handle this error in code, am i missing a method to check if ancestors/parent is published or should Umbraco handle the scenario of a parent/ancestor being unpublished ?
Umbraco examine YSOD in search results
Hi Umbraco Team
I have simple search page using the following code straight off our Umbraco Examine quick start guide Umbraco Examine quick start guide
my view
I get back results as expected. Issue arises when content editor unpublishes a parent/ancestor node, this leads to a YSOD when the search results contain a published node under the unpublished node.
Object reference not set to an instance of an object. on line
I'm using Umbraco 8 External Index making use of default standardanalyzer. Im not sure how to handle this error in code, am i missing a method to check if ancestors/parent is published or should Umbraco handle the scenario of a parent/ancestor being unpublished ?
Fixed in v8.9.1 https://github.com/umbraco/Umbraco-CMS/issues/8879
is working on a reply...