在弹性搜索中增加ignore_above属性



我正在使用弹性搜索和嵌套 5.0

我需要将ignore_above从默认值 256 增加到 512。

我可以通过属性映射来做到这一点吗?

否则,我如何使用流畅的 API 来执行此操作?

您可以使用

[Keyword(IgnoreAbove=512)]来更改值:

[ElasticsearchType(Name = "mytype")]
class mytype
{
    // default: will be mapped to both keyword (keyword search) 
    // and text (full-text search)
    public string defaultString { get; set; }
    // by default ignore above is set to 256 
    [Keyword]
    public string keywordType { get; set; }
    // change ignore above
    [Keyword(IgnoreAbove=512)]
    public string longKeyword { get; set; }
    // text type, full-text search
    [Text]
    public string textType { get; set; }
    // store but not searched
    [Text(Index = false)]
    public string textTypeNotSearchable { get; set; }
}

这是在 ElasticSearch 中为上述类型创建的索引:

"defaultString": {
    "type": "text",
    "fields": {
      "keyword": {
        "type": "keyword",
        "ignore_above": 256
      }
    }
  },
  "keywordType": {
    "type": "keyword"
  },
  "longKeyword": {
    "type": "keyword",
    "ignore_above": 512
  },
  "textType": {
    "type": "text"
  },
  "textTypeNotSearchable": {
    "type": "text",
    "index": false
  }  

最新更新