Skip to content

Commit

Permalink
NEST 6.X升级到7.X
Browse files Browse the repository at this point in the history
因为升级NEST导致的代码调整
  • Loading branch information
PuzzledAlien committed Jul 11, 2019
1 parent cac860b commit 1ccfb92
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions ElasticSearch/BulkAll/BulkAll/ElasticSearchBulk.cs
Expand Up @@ -10,7 +10,7 @@ public class ElasticSearchBulk
{ {
public static bool CreateIndex<T>(IElasticClient elasticClient, string indexName) where T : class public static bool CreateIndex<T>(IElasticClient elasticClient, string indexName) where T : class
{ {
var existsResponse = elasticClient.IndexExists(indexName); var existsResponse = elasticClient.Indices.Exists(indexName);
// 存在则返回true 不存在创建 // 存在则返回true 不存在创建
if (existsResponse.Exists) if (existsResponse.Exists)
{ {
Expand All @@ -26,8 +26,8 @@ public class ElasticSearchBulk
} }
}; };


ICreateIndexResponse response = elasticClient.CreateIndex(indexName, p => p CreateIndexResponse response = elasticClient.Indices.Create(indexName, p => p
.InitializeUsing(indexState).Mappings(m => m.Map<T>(r => r.AutoMap())) .InitializeUsing(indexState).Map<T>(r => r.AutoMap())
); );


return response.IsValid; return response.IsValid;
Expand Down
Expand Up @@ -6,7 +6,7 @@
</PropertyGroup> </PropertyGroup>


<ItemGroup> <ItemGroup>
<PackageReference Include="NEST" Version="6.5.1" /> <PackageReference Include="NEST" Version="7.0.1" />
</ItemGroup> </ItemGroup>


</Project> </Project>
6 changes: 3 additions & 3 deletions ElasticSearch/CreateIndex/ConsoleApp_CreateIndex/Program.cs
Expand Up @@ -14,7 +14,7 @@ static void Main(string[] args)
_indexName = _indexName.ToLower();//索引名称一定要小写 _indexName = _indexName.ToLower();//索引名称一定要小写
_elasticClient = GetElasticClientByPool(); _elasticClient = GetElasticClientByPool();


var existsResponse = _elasticClient.IndexExists(_indexName); var existsResponse = _elasticClient.Indices.Exists(_indexName);
if (!existsResponse.Exists) if (!existsResponse.Exists)
{ {
//基本配置 //基本配置
Expand All @@ -27,9 +27,9 @@ static void Main(string[] args)
} }
}; };


ICreateIndexResponse response = _elasticClient.CreateIndex(_indexName, p => p CreateIndexResponse response = _elasticClient.Indices.Create(_indexName, p => p
.InitializeUsing(indexState) .InitializeUsing(indexState)
.Mappings(m => m.Map<People>(r => r.AutoMap())) .Map<People>(r => r.AutoMap())
); );


if (response.IsValid) if (response.IsValid)
Expand Down

2 comments on commit 1ccfb92

@PuzzledAlien
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@PuzzledAlien
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.