嗨,我在Umbraco 7上进行了搜索,它工作正常,但我必须在索引中添加很多搜索字段,这不切实际。如何搜索所有字段?
@{ 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> }