Amending search code to also include results for umbraco tags
I can search my site and it checks for the searched word within each page of my site. However, I've also added tags to my pages using umbraco's built in system. Now I also need to return any successful searches that also match with my tags. But I've no idea how I can do this.
My search results controller looks like this:
public ActionResult SearchResults()
{
SearchResultsModel searchResultsModel = new SearchResultsModel();
if (!string.IsNullOrEmpty(Request.QueryString["term"].ToString()))
{
string searchTerm = Request.QueryString["term"].ToString();
int itemsPerPage = 5;
int currentPage = 1;
if (!int.TryParse(Request.QueryString["Page"], out currentPage))
currentPage = 1;
currentPage--;
//the searcher instance to use - Umbraco has 3 by default - InternalSearcher, ExternalSearcher and InternalMemberSearcher
var searcher = ExamineManager.Instance.SearchProviderCollection["ExternalSearcher"];
ISearchCriteria searchCriteria = searcher.CreateSearchCriteria(BooleanOperation.Or);
//define node properties to be searched
ISearchCriteria query = searchCriteria.GroupedOr(new string[] { "nodeName", "name", "heading", "bodyText", "summary" }, searchTerm).Compile();
ISearchResults searchResults = searcher.Search(searchCriteria);
IEnumerable<SearchResult> resultSet = searchResults.Skip(currentPage * itemsPerPage).Take(itemsPerPage);
int resultCount = searchResults.Count();
decimal pageCount = Math.Ceiling((decimal)((resultCount - 1) / itemsPerPage)) + 1;
//var pages = Enumerable.Range(1, (int)pageCount);
//set model properties
searchResultsModel.ResultSet = resultSet;
searchResultsModel.SearchTerm = searchTerm;
searchResultsModel.CurrentPage = currentPage;
searchResultsModel.NumberOfPages = pageCount;
searchResultsModel.ItemsPerPage = itemsPerPage;
}
return View(searchResultsModel);
}
Is what I'm wanting to do a simply ammendment me of the above? Or something far more complex?
Amending search code to also include results for umbraco tags
I can search my site and it checks for the searched word within each page of my site. However, I've also added tags to my pages using umbraco's built in system. Now I also need to return any successful searches that also match with my tags. But I've no idea how I can do this.
My search results controller looks like this:
Is what I'm wanting to do a simply ammendment me of the above? Or something far more complex?
is working on a reply...