本文整理汇总了C#中Nest.ElasticClient.Map方法的典型用法代码示例。如果您正苦于以下问题:C# ElasticClient.Map方法的具体用法?C# ElasticClient.Map怎么用?C# ElasticClient.Map使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Nest.ElasticClient
的用法示例。
在下文中一共展示了ElasticClient.Map方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Execute
public IResponse Execute()
{
// create client connection
var node = new Uri(ServerUrl);
var conn = new ConnectionSettings(node, this.IndexName);
var client = new ElasticClient(conn);
// check index name existance
var existenceResult = client.GetIndex(i => i.Index(IndexName));
if (existenceResult.ConnectionStatus.Success)
{
// delete exist index
var deleteResult = client.DeleteIndex(i => i.Index(IndexName));
if (!deleteResult.Acknowledged)
return deleteResult;
}
// create index
var createResult = client.CreateIndex(i => i.Index(IndexName));
if (!createResult.Acknowledged)
return createResult;
// set analyzer
SetAnalyzers(client);
// put mapping
var putResult = client.Map<TranslationMemory>(m => m.Index(this.IndexName).MapFromAttributes());
//var putResult = client.Map<ElasticSearchProject>(m => m.Index(this.IndexName));
return putResult;
}
示例2: CreateEmployee
private bool CreateEmployee(ElasticClient client)
{
var response = client.Map<Employee>(u => u
.Index(ElasticMappingConstants.INDEX_NAME)
.Type(ElasticMappingConstants.TYPE_EMPLOYEE)
.AllField(af => af.Enabled())
.MapFromAttributes()
);
return response.Acknowledged;
}
示例3: CreateProduct
private bool CreateProduct(ElasticClient client)
{
var response = client.Map<Product>(u => u
.Index(ElasticMappingConstants.INDEX_NAME)
.Type(ElasticMappingConstants.TYPE_PRODUCT)
.AllField(af => af.Enabled())
.MapFromAttributes()
);
return response.Acknowledged;
}
示例4: CreateIndex
/// <summary>
/// 创建索引
/// </summary>
public void CreateIndex()
{
string espath = ConfigurationManager.AppSettings["ESPath"].ToString();
string indexname = ConfigurationManager.AppSettings["IndexName"].ToString();
string typename = ConfigurationManager.AppSettings["TypeName"].ToString();
var node = new Uri(espath);
var settings = new ConnectionSettings(node);
var client = new ElasticClient(settings);
var newbase = new NewsBase();
client.CreateIndex(indexname);
client.Map<NewsBase>(m => m.MapFromAttributes());
}
示例5: ElasticsearchClient
public ElasticsearchClient()
{
this.connexion = new Uri("http://10.188.197.209:9200");
//this.connexion = new Uri("http://localhost:9200");
// this.connexion = new Uri("http://192.168.1.14:9200");
this.connexion = new Uri("http://localhost:9200");
this.settings = new ConnectionSettings(connexion, defaultIndex: "tp");
this.client = new ElasticClient(settings);
client.CreateIndex("tp");
var mapResult = client.Map<Stockobject>(c => c.MapFromAttributes().IgnoreConflicts().Type("stocks").Indices("tp"));
}
示例6: EsClient
/// Constructor
public EsClient()
{
var node = new Uri(ElasticUri);
_settings = new ConnectionSettings(node);
_settings.SetDefaultIndex(ConfigurationManager.AppSettings["DefaultIndex"]);
_settings.MapDefaultTypeNames(m => m.Add(typeof(HadoopMetaDataModels), ConfigurationManager.AppSettings["DefaultIndexType"]));
Current = new ElasticClient(_settings);
Current.Map<HadoopMetaDataModels>(m => m
.MapFromAttributes());
}
示例7: CreateSalesInfo
private bool CreateSalesInfo(ElasticClient client)
{
var response = client.Map<SalesInfo>(u => u
.Index(ElasticMappingConstants.INDEX_NAME)
.Type(ElasticMappingConstants.TYPE_SALES_INFO)
.AllField(af => af.Enabled())
.MapFromAttributes()
);
return response.Acknowledged;
}