Obsolete code updated to correct usages
Updates most of the code in the umbraco examine indexers to use current (non deprecated examine code)
This commit is contained in:
@@ -6,6 +6,7 @@ using System.IO;
|
||||
using System.Linq;
|
||||
using System.Xml.XPath;
|
||||
using Examine;
|
||||
using Examine.LuceneEngine;
|
||||
using Examine.LuceneEngine.Providers;
|
||||
using Examine.LuceneEngine.SearchCriteria;
|
||||
using Examine.Providers;
|
||||
@@ -158,7 +159,7 @@ namespace Umbraco.Web.PublishedCache.XmlPublishedCache
|
||||
try
|
||||
{
|
||||
//by default use the InternalSearcher
|
||||
return eMgr.GetSearcher("InternalSearcher");
|
||||
return eMgr.GetSearcher(Constants.Examine.InternalIndexer);
|
||||
}
|
||||
catch (FileNotFoundException)
|
||||
{
|
||||
@@ -411,30 +412,17 @@ namespace Umbraco.Web.PublishedCache.XmlPublishedCache
|
||||
try
|
||||
{
|
||||
//first check in Examine as this is WAY faster
|
||||
var criteria = searchProvider.CreateSearchCriteria("media");
|
||||
var criteria = searchProvider.CreateCriteria("media");
|
||||
|
||||
var filter = criteria.ParentId(parentId).Not().Field(UmbracoContentIndexer.IndexPathFieldName, "-1,-21,".MultipleCharacterWildcard());
|
||||
var filter = criteria.ParentId(parentId).Not().Field(BaseUmbracoIndexer.IndexPathFieldName, "-1,-21,".MultipleCharacterWildcard());
|
||||
//the above filter will create a query like this, NOTE: That since the use of the wildcard, it automatically escapes it in Lucene.
|
||||
//+(+parentId:3113 -__Path:-1,-21,*) +__IndexType:media
|
||||
|
||||
ISearchResults results;
|
||||
//sort with the Sort field
|
||||
var results = searchProvider.Find(
|
||||
filter.And().OrderBy(new SortableField("sortOrder", SortType.Int)).Compile());
|
||||
|
||||
//we want to check if the indexer for this searcher has "sortOrder" flagged as sortable.
|
||||
//if so, we'll use Lucene to do the sorting, if not we'll have to manually sort it (slower).
|
||||
var indexer = GetIndexProviderSafe();
|
||||
var useLuceneSort = indexer != null && indexer.IndexerData.StandardFields.Any(x => x.Name.InvariantEquals("sortOrder") && x.EnableSorting);
|
||||
if (useLuceneSort)
|
||||
{
|
||||
//we have a sortOrder field declared to be sorted, so we'll use Examine
|
||||
results = searchProvider.Search(
|
||||
filter.And().OrderBy(new SortableField("sortOrder", SortType.Int)).Compile());
|
||||
}
|
||||
else
|
||||
{
|
||||
results = searchProvider.Search(filter.Compile());
|
||||
}
|
||||
|
||||
if (results.Any())
|
||||
if (results.Any())
|
||||
{
|
||||
// var medias = results.Select(ConvertFromSearchResult);
|
||||
var medias = results.Select(x =>
|
||||
@@ -446,7 +434,7 @@ namespace Umbraco.Web.PublishedCache.XmlPublishedCache
|
||||
return CreateFromCacheValues(cacheValues);
|
||||
});
|
||||
|
||||
return useLuceneSort ? medias : medias.OrderBy(x => x.SortOrder);
|
||||
return medias;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -562,17 +550,13 @@ namespace Umbraco.Web.PublishedCache.XmlPublishedCache
|
||||
LoadedFromExamine = fromExamine;
|
||||
|
||||
ValidateAndSetProperty(valueDictionary, val => _id = int.Parse(val), "id", "nodeId", "__NodeId"); //should validate the int!
|
||||
ValidateAndSetProperty(valueDictionary, val => _key = Guid.Parse(val), "key");
|
||||
// wtf are we dealing with templates for medias?!
|
||||
ValidateAndSetProperty(valueDictionary, val => _templateId = int.Parse(val), "template", "templateId");
|
||||
ValidateAndSetProperty(valueDictionary, val => _key = Guid.Parse(val), "key");
|
||||
ValidateAndSetProperty(valueDictionary, val => _sortOrder = int.Parse(val), "sortOrder");
|
||||
ValidateAndSetProperty(valueDictionary, val => _name = val, "nodeName", "__nodeName");
|
||||
ValidateAndSetProperty(valueDictionary, val => _urlName = val, "urlName");
|
||||
ValidateAndSetProperty(valueDictionary, val => _documentTypeAlias = val, "nodeTypeAlias", UmbracoContentIndexer.NodeTypeAliasFieldName);
|
||||
ValidateAndSetProperty(valueDictionary, val => _documentTypeAlias = val, "nodeTypeAlias", LuceneIndexer.NodeTypeAliasFieldName);
|
||||
ValidateAndSetProperty(valueDictionary, val => _documentTypeId = int.Parse(val), "nodeType");
|
||||
ValidateAndSetProperty(valueDictionary, val => _writerName = val, "writerName");
|
||||
ValidateAndSetProperty(valueDictionary, val => _creatorName = val, "creatorName", "writerName"); //this is a bit of a hack fix for: U4-1132
|
||||
ValidateAndSetProperty(valueDictionary, val => _writerId = int.Parse(val), "writerID");
|
||||
ValidateAndSetProperty(valueDictionary, val => _creatorId = int.Parse(val), "creatorID", "writerID"); //this is a bit of a hack fix for: U4-1132
|
||||
ValidateAndSetProperty(valueDictionary, val => _path = val, "path", "__Path");
|
||||
ValidateAndSetProperty(valueDictionary, val => _createDate = ParseDateTimeValue(val), "createDate");
|
||||
@@ -668,16 +652,12 @@ namespace Umbraco.Web.PublishedCache.XmlPublishedCache
|
||||
|
||||
public override Guid Key { get { return _key; } }
|
||||
|
||||
public override int TemplateId
|
||||
{
|
||||
get
|
||||
{
|
||||
//TODO: should probably throw a not supported exception since media doesn't actually support this.
|
||||
return _templateId;
|
||||
}
|
||||
}
|
||||
public override int TemplateId
|
||||
{
|
||||
get { return 0; }
|
||||
}
|
||||
|
||||
public override int SortOrder
|
||||
public override int SortOrder
|
||||
{
|
||||
get { return _sortOrder; }
|
||||
}
|
||||
@@ -704,7 +684,7 @@ namespace Umbraco.Web.PublishedCache.XmlPublishedCache
|
||||
|
||||
public override string WriterName
|
||||
{
|
||||
get { return _writerName; }
|
||||
get { return _creatorName; }
|
||||
}
|
||||
|
||||
public override string CreatorName
|
||||
@@ -714,7 +694,7 @@ namespace Umbraco.Web.PublishedCache.XmlPublishedCache
|
||||
|
||||
public override int WriterId
|
||||
{
|
||||
get { return _writerId; }
|
||||
get { return _creatorId; }
|
||||
}
|
||||
|
||||
public override int CreatorId
|
||||
@@ -739,7 +719,7 @@ namespace Umbraco.Web.PublishedCache.XmlPublishedCache
|
||||
|
||||
public override Guid Version
|
||||
{
|
||||
get { return _version; }
|
||||
get { return Guid.Empty; }
|
||||
}
|
||||
|
||||
public override int Level
|
||||
@@ -808,20 +788,16 @@ namespace Umbraco.Web.PublishedCache.XmlPublishedCache
|
||||
private readonly List<string> _keysAdded = new List<string>();
|
||||
private int _id;
|
||||
private Guid _key;
|
||||
private int _templateId;
|
||||
private int _sortOrder;
|
||||
private string _name;
|
||||
private string _urlName;
|
||||
private string _documentTypeAlias;
|
||||
private int _documentTypeId;
|
||||
private string _writerName;
|
||||
private int _documentTypeId;
|
||||
private string _creatorName;
|
||||
private int _writerId;
|
||||
private int _creatorId;
|
||||
private string _path;
|
||||
private DateTime _createDate;
|
||||
private DateTime _updateDate;
|
||||
private Guid _version;
|
||||
private int _level;
|
||||
private readonly ICollection<IPublishedProperty> _properties;
|
||||
private readonly PublishedContentType _contentType;
|
||||
|
||||
Reference in New Issue
Block a user