【问题标题】:elasticsearch autocompletion mapping using nest使用嵌套的elasticsearch自动完成映射
【发布时间】:2015-12-31 17:45:31
【问题描述】:

我正在使用nest 在.net 中实现elasticsearch,并且是新手。我正在尝试映射建议者,请帮助我。如何在 c# 中使用嵌套来做到这一点

curl -X PUT localhost:9200/songs/song/_mapping -d '{
    "song" : {
        "properties" : {
            "name" : { "type" : "string" },
            "suggest" : { "type" : "completion",
                "index_analyzer" : "simple",
                "search_analyzer" : "simple",
                "payloads" : true
            }
        }
    }
}'

【问题讨论】:

  • 有什么问题?什么不工作?
  • 如何在c#中使用nest做到这一点?

标签: c# .net elasticsearch autocomplete nest


【解决方案1】:

在下面找到完整的代码。它创建一个新的ElasticClient 对象,然后将映射song 添加到索引songs。在执行此代码之前,请确保索引 songs 已经存在。您也可以在通过代码创建映射之前创建索引songs。我会把它留给你来弄清楚。查找如何在 Nest here 中创建映射的详尽示例。

var client = new ElasticClient(new ConnectionSettings(new Uri("http://localhost:9200")));

var response = client.Map<object>(d => d
    .Index("songs")
    .Type("song")
    .Properties(props => props
        .String(s => s
            .Name("name"))
        .Completion(c => c
            .Name("suggest")
            .IndexAnalyzer("simple")
            .SearchAnalyzer("simple")
            .Payloads())));

Debug.Assert(response.IsValid);

【讨论】:

  • @bittusarkar 你能帮我解决这个问题吗problem
  • PutMappingDescriptor 上没有名为 Type 的属性
猜你喜欢
  • 2014-09-26
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-07-21
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-01-20
相关资源
最近更新 更多