Files
Umbraco-CMS/src/Umbraco.Web/ExamineExtensions.cs
Shannon Deminick 5aee883bd2 Added TypedSearch methods to UmbracoHelper and Search extension methods to the IPublishedContent.
Added GetTemplateAlias() extension method to IPublishedContent and to DynamicPublishedContent.
2012-10-18 08:00:07 +05:00

40 lines
1.2 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Xml;
using Examine;
using Umbraco.Core.Dynamics;
using Umbraco.Core.Models;
using Umbraco.Web.Models;
namespace Umbraco.Web
{
/// <summary>
/// Extension methods for Examine
/// </summary>
internal static class ExamineExtensions
{
internal static IEnumerable<IPublishedContent> ConvertSearchResultToPublishedContent(
this IEnumerable<SearchResult> results,
IPublishedStore store)
{
//TODO: The search result has already returned a result which SHOULD include all of the data to create an IPublishedContent,
// however thsi is currently not the case:
// http://examine.codeplex.com/workitem/10350
var list = new List<IPublishedContent>();
foreach (var result in results.OrderByDescending(x => x.Score))
{
var doc = store.GetDocumentById(
UmbracoContext.Current,
result.Id);
if (doc == null) continue; //skip if this doesn't exist in the cache
doc.Properties.Add(
new PropertyResult("examineScore", result.Score.ToString(), Guid.Empty, PropertyResultType.CustomProperty));
list.Add(doc);
}
return list;
}
}
}