Skip to content

Commit

Permalink
add rules only for umbraco
Browse files Browse the repository at this point in the history
  • Loading branch information
arkadiuszbiel committed Nov 14, 2019
1 parent 0feaa31 commit 72b7d34
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public class ElasticSearchBaseIndex : BaseIndexProvider, IDisposable
{
public readonly ElasticSearchConfig _connectionConfiguration;
private bool isReindexing = false;

private bool _isUmbraco = false;
public readonly Lazy<ElasticClient> _client;
private ElasticClient _indexer;
private static readonly object ExistsLocker = new object();
Expand All @@ -44,12 +44,12 @@ public ElasticSearchBaseIndex(string name,
ElasticSearchConfig connectionConfiguration,
FieldDefinitionCollection fieldDefinitions = null,
string analyzer = null,
IValueSetValidator validator = null)
IValueSetValidator validator = null, bool isUmbraco = false)
: base(name.ToLowerInvariant(), //TODO: Need to 'clean' the name according to Azure Search rules
fieldDefinitions ?? new FieldDefinitionCollection(), validator)
{
_connectionConfiguration = connectionConfiguration;

_isUmbraco = isUmbraco;
Analyzer = analyzer;
ElasticURL = ConfigurationManager.AppSettings[$"examine:ElasticSearch[{name}].Url"];
_searcher = new Lazy<ElasticSearchSearcher>(CreateSearcher);
Expand Down Expand Up @@ -267,9 +267,18 @@ private BulkDescriptor ToElasticSearchDocs(IEnumerable<ValueSet> docs, string in

protected override void PerformIndexItems(IEnumerable<ValueSet> op, Action<IndexOperationEventArgs> onComplete)
{
if (!IndexExists() && !TempIndexExists()) return;
if (!IndexExists() && !TempIndexExists())
{
return;
}
if(!_isUmbraco)
{
EnsureIndex(false);
}

var indexesMappedToAlias = _client.Value.GetAlias(descriptor => descriptor.Name(indexAlias))
.Indices.Select(x => x.Key).ToList();


var indexTarget = isReindexing ? tempindexAlias : indexAlias;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ protected ElasticSearchUmbracoIndex(string name,
FieldDefinitionCollection fieldDefinitions = null,
string analyzer = null,
IValueSetValidator validator = null)
: base(name, connectionConfiguration, fieldDefinitions, analyzer, validator)
: base(name, connectionConfiguration, fieldDefinitions, analyzer, validator,true)
{
_logger = profilingLogger;
}
Expand Down

0 comments on commit 72b7d34

Please sign in to comment.