2016-07-12 2 views
2

콘텐츠 편집기가 검색 페이지에서 항목을 제외 할 수있는 옵션을 허용하려고합니다. 검색중인 템플릿에는 표시 여부를 나타내는 확인란이 있습니다. Sitecore.Search.Crawlers.DatabaseCrawler를 상속하고 AddItem 메서드 (Excluding items selectively from Sitecore's Lucene search index - works when rebuilding with IndexViewer, but not when using Sitecore's built-in tools)를 재정의하는 것과 관련된 몇 가지 대답을 보았습니다. 하지만 제어판에서 색인을 다시 작성할 때이 문제가 발생하지는 않습니다. Sitecore.ContentSearch.SitecoreItemCrawler에서 RebuildFromRoot 메서드를 호출 할 수있었습니다. 누구든지 그 질문에서 DatabaseCrawler 메서드가 정확히 때 알 수 있습니까? 나는 사용자 정의 SitecoreItemCrawler와 DatabaseCrawler를 모두 사용해야 할 필요가 있지만 나는 긍정적이지 않다는 느낌이 들었다. 모든 통찰력은 인정 될 것이다. Sitecore 8.0 (개정판 150621)을 사용하고 있습니다.Sitecore Lucene 색인에서 항목 제외

Sitecore의 기본 루씬 크롤러 구현에서
+2

콘텐츠 편집기가 색인에서 항목을 제외시키지 않고 검색 결과를 구체화하는 것이 더 좋습니까? –

답변

7

상속 및 색인에서 항목을 제외 할 진정한 복귀는 IsExcludedFromIndex 메소드를 오버라이드 (override) 다음 IndexUpdateNeedDelete 방법은 항목 경우 인덱스에서 항목을 제거 할 필요가

using Sitecore.ContentSearch; 
using Sitecore.Data.Items; 

namespace MyProject.CMS.Custom.ContentSearch.Crawlers 
{ 
    public class CustomCoveoItemCrawler : Sitecore.ContentSearch.SitecoreItemCrawler 
    { 
     protected override bool IsExcludedFromIndex(SitecoreIndexableItem indexable, bool checkLocation = false) 
     { 
      bool isExcluded = base.IsExcludedFromIndex(indexable, checkLocation); 

      if (isExcluded) 
       return true; 

      Item obj = (Item)indexable; 

      if (obj["Exclude From Index"] != "1") //or whatever logic you need 
       return true; 

      return false; 
     } 

     protected override bool IndexUpdateNeedDelete(SitecoreIndexableItem indexable) 
     { 
      Item obj = indexable; 
      return obj["Exclude From Index"] == "1"; 
     } 
    } 
} 

미래의 날짜에 업데이트됩니다.

인덱스가 필요한 크롤러를 대체하려면 패치 파일을 사용하십시오.

<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/"> 
    <sitecore>  
    <contentSearch> 

     <configuration> 
     <indexes> 
      <index id="sitecore_master_index"> 
      <locations> 
       <crawler> 
       <patch:attribute name="type">MyProject.CMS.Custom.ContentSearch.Crawlers.CustomCoveoItemCrawler, MyProject.CMS.Custom</patch:attribute> 
       </crawler> 
      </locations> 
      </index> 
      ... 
     </indexes> 
     </configuration> 

    </contentSearch> 
    </sitecore> 
</configuration> 

이후에는 항목을 제외시키기 위해 색인을 다시 작성해야합니다 (제어판에서 사용 가능).

+0

그리고 특별한 이유가없는 한 @IanGraham이 필터를 사용하여 검색 결과에서 제외하는 것에 동의합니다. 보통 양식을 제외 시키십시오. – jammykam

+0

유일하게 진짜 이유는 우리가 인덱스를 칠 때마다 여분의 매개 변수로 필터링 할 것이기 때문에 약간의 (오버 헤드만큼 중요하지 않은) 오버 헤드를 추가해야한다는 것입니다. 확실히 더 쉽게되었을 것 같습니다. 나는 그 길을 가기 전에 당신이 제안한 것을 시도하고 싶습니다. – Teeknow

+0

'contentSearch.getGlobalLinqFilters' 파이프 라인을 살펴볼 수는 있지만, _may_는 ** 모든 ** 인덱스 ** 모든 ** 시간에 적용됩니다. 또한, 인덱스에서 항목을 제외시키기위한'indexing.filterIndex.inbound' 파이프 라인을 살펴보십시오. 이것은 다시 모든 인덱스에 걸쳐 적용될 수 있습니다. 하지만 Sitecore가 CMS에서 자체 검색을 위해 내부적으로이를 사용하기 때문에 코어/마스터/웹 색인에 대해서는이 기능을 사용하지 않을 수 있습니다. 솔루션 btw 줄 경우이 크롤러를 사용하는 사용자 지정 인덱스를 만들어야합니다. – jammykam