Hi i have search on Umbraco 7 and it works OK, but i have to add a lot of search fields to index and it´s not practic. How can i search through all fields instead of adding them manually?
@{
string searchQuery = Request["query"];
if (String.IsNullOrWhiteSpace(searchQuery))
{
searchQuery = "";
}
var searcher = ExamineManager.Instance;
var searchCriteria = searcher.CreateSearchCriteria();
var query = searchCriteria.GroupedOr(new[] {
"nodeName",
//"packSizes",
"name",
"title",
"bodyText",
"body",
"field1",
"field2",
"field3",
"field4",
"field5",
"field6"
}, searchQuery).Compile();
var SearchResults = searcher.Search(query).Where(x => x["__IndexType"] == "content").ToList();
}
@if (SearchResults.Any())
{
<ul class="search-results-box">
@foreach (var result in SearchResults)
{
var node = Umbraco.TypedContent(result.Id);
var pathIds = result["__Path"].Split(',');
var path = Umbraco.TypedContent(pathIds).Where(p => p != null).Select(p => new { p.Name }).ToList();
if (node != null)
{
<li><a href="@node.Url">@node.Name</a></li>
}
}
</ul>
}
Search in all fields
Hi i have search on Umbraco 7 and it works OK, but i have to add a lot of search fields to index and it´s not practic. How can i search through all fields instead of adding them manually?
is working on a reply...