Skip to content

Commit 75147dd

Browse files
committed
修复判断es索引不存在时的处理方式
1 parent 347e2d9 commit 75147dd

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@ obj
55
packages
66
/.vs
77
*.idea
8-
/.idea/
8+
/.idea/
9+
.DS_Store

Framework/Farseer.Net.ElasticSearch/IndexSet.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,7 @@ public List<TDocument> ToList(int pageSize, int pageIndex, out long recordCount)
379379

380380
if (!searchResponse.IsValid)
381381
{
382-
if (searchResponse.ServerError.Error.Type == "index_not_found_exception") return new List<TDocument>();
382+
if (searchResponse.ApiCall.HttpStatusCode == 404) return new List<TDocument>();
383383
throw searchResponse.OriginalException;
384384
}
385385

@@ -405,7 +405,7 @@ public TValue GetValue<TValue>(Expression<Func<TDocument, object>> select)
405405

406406
if (!searchResponse.IsValid)
407407
{
408-
if (searchResponse.ServerError.Error.Type == "index_not_found_exception") return default;
408+
if (searchResponse.ApiCall.HttpStatusCode == 404) return default;
409409
throw searchResponse.OriginalException;
410410
}
411411

@@ -431,7 +431,7 @@ public async Task<TValue> GetValueAsync<TValue>(Expression<Func<TDocument, objec
431431

432432
if (!searchResponse.IsValid)
433433
{
434-
if (searchResponse.ServerError.Error.Type == "index_not_found_exception") return default;
434+
if (searchResponse.ServerError?.Error.Type == "index_not_found_exception") return default;
435435
throw searchResponse.OriginalException;
436436
}
437437

0 commit comments

Comments
 (0)