Umbraco Search - How do I tell what doc type a search result is?
I am using umbraco search / lucene in my project and I am getting the results I want.
but I want to treat search results that are of a certain doc type differently, how do I determine a doc type from search results?
Heres what I have so far.
var Searcher = Examine.ExamineManager.Instance.SearchProviderCollection["ExternalSearcher"];
var searchCriteria = Searcher.CreateSearchCriteria(Examine.SearchCriteria.BooleanOperation.Or);
var query = searchCriteria.Field("nodeName", q.Boost(3)).Or().Field("description", q.Boost(3)).Or().Field("bodyText", q.Fuzzy()).Or().Field("content", q.Boost(3));
var searchResults = Searcher.Search(query.Compile()).OrderByDescending(x => x.Score).TakeWhile(x => x.Score > 0.05f);
@foreach (var item in searchResults)
{
//if item is doc type... bla bla bla
}
Umbraco Search - How do I tell what doc type a search result is?
I am using umbraco search / lucene in my project and I am getting the results I want.
but I want to treat search results that are of a certain doc type differently, how do I determine a doc type from search results?
Heres what I have so far.
Hi Ayo
According to the Razor cheat sheet https://our.umbraco.org/projects/developer-tools/umbraco-v6-mvc-razor-cheatsheets you should be able to simply do item.DocumentTypeAlias === "youralias" - You might need to cast it as a string though so perhaps item.DocumentTypeAlias.ToString() === "youralias" is better.
Does that work?
/Jan
is working on a reply...