|
|
|
@ -41,7 +41,7 @@ public class ElasticSearchIndex : ISearchIndex
@@ -41,7 +41,7 @@ public class ElasticSearchIndex : ISearchIndex
|
|
|
|
|
|
|
|
|
|
public async Task<bool> IndexExists() |
|
|
|
|
{ |
|
|
|
|
_client ??= new ElasticsearchClient(Uri); |
|
|
|
|
_client ??= CreateClient(); |
|
|
|
|
ExistsResponse exists = await _client.Indices.ExistsAsync(IndexName); |
|
|
|
|
return exists.IsValidResponse; |
|
|
|
|
} |
|
|
|
@ -52,7 +52,8 @@ public class ElasticSearchIndex : ISearchIndex
@@ -52,7 +52,8 @@ public class ElasticSearchIndex : ISearchIndex
|
|
|
|
|
ILocalFileSystem localFileSystem, |
|
|
|
|
IConfigElementRepository configElementRepository) |
|
|
|
|
{ |
|
|
|
|
_client ??= new ElasticsearchClient(Uri); |
|
|
|
|
_client ??= CreateClient(); |
|
|
|
|
|
|
|
|
|
ExistsResponse exists = await _client.Indices.ExistsAsync(IndexName); |
|
|
|
|
if (!exists.IsValidResponse) |
|
|
|
|
{ |
|
|
|
@ -159,7 +160,7 @@ public class ElasticSearchIndex : ISearchIndex
@@ -159,7 +160,7 @@ public class ElasticSearchIndex : ISearchIndex
|
|
|
|
|
var totalCount = 0; |
|
|
|
|
|
|
|
|
|
Query parsedQuery = LuceneSearchIndex.ParseQuery(query); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SearchResponse<MinimalElasticSearchItem> response = await _client.SearchAsync<MinimalElasticSearchItem>( |
|
|
|
|
s => s.Index(IndexName) |
|
|
|
|
.Sort(ss => ss.Field(f => f.SortTitle, fs => fs.Order(SortOrder.Asc))) |
|
|
|
@ -188,6 +189,12 @@ public class ElasticSearchIndex : ISearchIndex
@@ -188,6 +189,12 @@ public class ElasticSearchIndex : ISearchIndex
|
|
|
|
|
// do nothing
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private static ElasticsearchClient CreateClient() |
|
|
|
|
{ |
|
|
|
|
ElasticsearchClientSettings settings = new ElasticsearchClientSettings(Uri).DefaultIndex(IndexName); |
|
|
|
|
return new ElasticsearchClient(settings); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private async Task<CreateIndexResponse> CreateIndex() => |
|
|
|
|
await _client.Indices.CreateAsync<ElasticSearchItem>( |
|
|
|
|
IndexName, |
|
|
|
|