if(ExamineManager.Instance.TryGetIndex("ExternalIndex", out var index))
{
var searcher = index.GetSearcher();
var textFields = new[] { "nodeName", "metaDescription_da-dk", "bodyText", "bodyText_da-dk"};
var results = searcher.CreateQuery("content").GroupedOr(textFields, 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><br/>
@node.Value("metaDescription")
</li>
}
}
</ul>
}
else
{
<p>No results found for query @searchTerm</p>
}
}
return;
}
}
But as it is now, i have to feed it all the document properties i want to search. Which could be ok, but its a multilingual site, so eg "bodyText" isn't searched, as it is bodyText_da-dk in Examine. So more work to keep in check. And even worse if the editor is allowed to create a new language... then this is not searched... So it would be nice to know a way to just search all fields..
Search all fields by default
So, i have this search working:
But as it is now, i have to feed it all the document properties i want to search. Which could be ok, but its a multilingual site, so eg "bodyText" isn't searched, as it is bodyText_da-dk in Examine. So more work to keep in check. And even worse if the editor is allowed to create a new language... then this is not searched... So it would be nice to know a way to just search all fields..
Thanks
Hey Claus,
Yes it is possible.
I believe if you use
This should search all fields.
Thanks
Nik
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.