Fixes more of #U4-1706 and adds another unit test. Ensures we never return items from the recycle bin even if the indexes exist. Updated logic to ensure

items don't get indexed even if they are saved and currently exist in the recycle bin and ensures that indexes are removed on both trashed
and deleted.
This commit is contained in:
Shannon Deminick
2013-02-20 00:13:35 +06:00
parent a2ea20de70
commit 0751aff31f
3 changed files with 66 additions and 16 deletions

View File

@@ -5,6 +5,7 @@ using System.IO;
using System.Linq;
using System.Xml.XPath;
using Examine;
using Examine.LuceneEngine.SearchCriteria;
using Examine.Providers;
using Lucene.Net.Documents;
using Umbraco.Core;
@@ -108,7 +109,11 @@ namespace Umbraco.Web
{
//first check in Examine as this is WAY faster
var criteria = searchProvider.CreateSearchCriteria("media");
var filter = criteria.Id(id).Not().Field(UmbracoContentIndexer.IndexPathFieldName, "-21");
var filter = criteria.Id(id).Not().Field(UmbracoContentIndexer.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.
//+(+__NodeId:3113 -__Path:-1,-21,*) +__IndexType:media
var results = searchProvider.Search(filter.Compile());
if (results.Any())
{