-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix the issue for 9.0.1, using roles an considering all search providers
- Loading branch information
1 parent
27ab937
commit 23c7e59
Showing
6 changed files
with
259 additions
and
45 deletions.
There are no files selected for viewing
14 changes: 12 additions & 2 deletions
14
src/Sitecore.Support.96931/App_Config/Include/zzz/Sitecore.Support.96931.config
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
94 changes: 94 additions & 0 deletions
94
src/Sitecore.Support.96931/ContentSearch/Azure/CloudSearchDocumentBuilder.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
namespace Sitecore.Support.ContentSearch.Azure | ||
{ | ||
using System; | ||
using System.Collections.Concurrent; | ||
using Sitecore.ContentSearch; | ||
using Sitecore.ContentSearch.Diagnostics; | ||
using Sitecore.Data.LanguageFallback; | ||
|
||
public class CloudSearchDocumentBuilder : Sitecore.ContentSearch.Azure.CloudSearchDocumentBuilder | ||
{ | ||
public CloudSearchDocumentBuilder(IIndexable indexable, IProviderUpdateContext context) : base(indexable, context) | ||
{ | ||
} | ||
|
||
protected override void AddComputedIndexFieldsInParallel() | ||
{ | ||
ConcurrentQueue<Exception> exceptions = new ConcurrentQueue<Exception>(); | ||
|
||
//ensure that we preserve current item-level language fallback setting when entering new threads | ||
var needEnterLanguageFallbackItemSwitcher = LanguageFallbackItemSwitcher.CurrentValue; | ||
|
||
this.ParallelForeachProxy.ForEach( | ||
this.Options.ComputedIndexFields, | ||
this.ParallelOptions, | ||
(computedIndexField, parallelLoopState) => | ||
{ | ||
object fieldValue; | ||
try | ||
{ | ||
using (new LanguageFallbackItemSwitcher(needEnterLanguageFallbackItemSwitcher)) | ||
{ | ||
//take field-level language fallback setting into accout (fix for issue #96931) | ||
using (new LanguageFallbackFieldSwitcher(this.Index.EnableFieldLanguageFallback)) | ||
{ | ||
fieldValue = computedIndexField.ComputeFieldValue(this.Indexable); | ||
} | ||
} | ||
} | ||
catch (Exception ex) | ||
{ | ||
CrawlingLog.Log.Warn( | ||
string.Format("Could not compute value for ComputedIndexField: {0} for indexable: {1}", | ||
computedIndexField.FieldName, this.Indexable.UniqueId), ex); | ||
if (this.Settings.StopOnCrawlFieldError()) | ||
{ | ||
exceptions.Enqueue(ex); | ||
parallelLoopState.Stop(); | ||
} | ||
System.Diagnostics.Debug.WriteLine(ex); | ||
return; | ||
} | ||
this.AddComputedIndexField(computedIndexField, fieldValue); | ||
}); | ||
|
||
if (!exceptions.IsEmpty) | ||
{ | ||
throw new AggregateException(exceptions); | ||
} | ||
} | ||
|
||
protected override void AddComputedIndexFieldsInSequence() | ||
{ | ||
foreach (var computedIndexField in this.Options.ComputedIndexFields) | ||
{ | ||
object fieldValue; | ||
|
||
try | ||
{ | ||
//take field-level language fallback setting into accout (fix for issue #96931) | ||
using (new LanguageFallbackFieldSwitcher(this.Index.EnableFieldLanguageFallback)) | ||
{ | ||
fieldValue = computedIndexField.ComputeFieldValue(this.Indexable); | ||
} | ||
} | ||
catch (Exception ex) | ||
{ | ||
CrawlingLog.Log.Warn(string.Format("Could not compute value for ComputedIndexField: {0} for indexable: {1}", computedIndexField.FieldName, this.Indexable.UniqueId), ex); | ||
if (this.Settings.StopOnCrawlFieldError()) | ||
{ | ||
throw; | ||
} | ||
|
||
System.Diagnostics.Debug.WriteLine(ex); | ||
continue; | ||
} | ||
|
||
this.AddComputedIndexField(computedIndexField, fieldValue); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
94 changes: 94 additions & 0 deletions
94
src/Sitecore.Support.96931/ContentSearch/SolrProvider/SolrDocumentBuilder.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
namespace Sitecore.Support.ContentSearch.SolrProvider | ||
{ | ||
using System; | ||
using System.Collections.Concurrent; | ||
using Sitecore.ContentSearch; | ||
using Sitecore.ContentSearch.Diagnostics; | ||
using Sitecore.Data.LanguageFallback; | ||
|
||
public class SolrDocumentBuilder : Sitecore.ContentSearch.SolrProvider.SolrDocumentBuilder | ||
{ | ||
public SolrDocumentBuilder(IIndexable indexable, IProviderUpdateContext context) : base(indexable, context) | ||
{ | ||
} | ||
|
||
protected override void AddComputedIndexFieldsInParallel() | ||
{ | ||
ConcurrentQueue<Exception> exceptions = new ConcurrentQueue<Exception>(); | ||
|
||
//ensure that we preserve current item-level language fallback setting when entering new threads | ||
var needEnterLanguageFallbackItemSwitcher = LanguageFallbackItemSwitcher.CurrentValue; | ||
|
||
this.ParallelForeachProxy.ForEach( | ||
this.Options.ComputedIndexFields, | ||
this.ParallelOptions, | ||
(computedIndexField, parallelLoopState) => | ||
{ | ||
object fieldValue; | ||
try | ||
{ | ||
using (new LanguageFallbackItemSwitcher(needEnterLanguageFallbackItemSwitcher)) | ||
{ | ||
//take field-level language fallback setting into accout (fix for issue #96931) | ||
using (new LanguageFallbackFieldSwitcher(this.Index.EnableFieldLanguageFallback)) | ||
{ | ||
fieldValue = computedIndexField.ComputeFieldValue(this.Indexable); | ||
} | ||
} | ||
} | ||
catch (Exception ex) | ||
{ | ||
CrawlingLog.Log.Warn( | ||
string.Format("Could not compute value for ComputedIndexField: {0} for indexable: {1}", | ||
computedIndexField.FieldName, this.Indexable.UniqueId), ex); | ||
if (this.Settings.StopOnCrawlFieldError()) | ||
{ | ||
exceptions.Enqueue(ex); | ||
parallelLoopState.Stop(); | ||
} | ||
System.Diagnostics.Debug.WriteLine(ex); | ||
return; | ||
} | ||
this.AddComputedIndexField(computedIndexField, fieldValue); | ||
}); | ||
|
||
if (!exceptions.IsEmpty) | ||
{ | ||
throw new AggregateException(exceptions); | ||
} | ||
} | ||
|
||
protected override void AddComputedIndexFieldsInSequence() | ||
{ | ||
foreach (var computedIndexField in this.Options.ComputedIndexFields) | ||
{ | ||
object fieldValue; | ||
|
||
try | ||
{ | ||
//take field-level language fallback setting into accout (fix for issue #96931) | ||
using (new LanguageFallbackFieldSwitcher(this.Index.EnableFieldLanguageFallback)) | ||
{ | ||
fieldValue = computedIndexField.ComputeFieldValue(this.Indexable); | ||
} | ||
} | ||
catch (Exception ex) | ||
{ | ||
CrawlingLog.Log.Warn(string.Format("Could not compute value for ComputedIndexField: {0} for indexable: {1}", computedIndexField.FieldName, this.Indexable.UniqueId), ex); | ||
if (this.Settings.StopOnCrawlFieldError()) | ||
{ | ||
throw; | ||
} | ||
|
||
System.Diagnostics.Debug.WriteLine(ex); | ||
continue; | ||
} | ||
|
||
this.AddComputedIndexField(computedIndexField, fieldValue); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.