0
点赞
收藏
分享

微信扫一扫

JWFD开源工作流-矩阵引擎设计-遍历排序算法运行测试

1. ignore_above

关于es mapping的keyword ignore_above配置项的解释如下:

2.测试

创建索引 test_keyword,指定长度超过10的数据不索引

PUT test_keyword
{
  "mappings": {
    "properties": {
      "name":{
        "type":"keyword",
        "ignore_above": 10
      }
    }
  }
}

向索引中写入数据:

PUT test_keyword/_doc/1
{
  "name":"1234567890"
}

PUT test_keyword/_doc/2
{
  "name":"12345678901"
}

查询数据,结果如下:

#可以查询到数据结果
GET test_keyword/_search
{
  "query":{
    "term": {
      "name": "1234567890"
    }
  }
}


#查询不到数据结果
GET test_keyword/_search
{
  "query":{
    "term": {
      "name": "12345678901"
    }
  }
}

在查询所有数据_source中可以看到“12345678901”这条数据,说明“12345678901”这条数据没有被索引。

GET test_keyword/_search


{
  "took" : 1,
  "timed_out" : false,
  "_shards" : {
    "total" : 1,
    "successful" : 1,
    "skipped" : 0,
    "failed" : 0
  },
  "hits" : {
    "total" : {
      "value" : 2,
      "relation" : "eq"
    },
    "max_score" : 1.0,
    "hits" : [
      {
        "_index" : "test_keyword",
        "_type" : "_doc",
        "_id" : "1",
        "_score" : 1.0,
        "_source" : {
          "name" : "1234567890"
        }
      },
      {
        "_index" : "test_keyword",
        "_type" : "_doc",
        "_id" : "2",
        "_score" : 1.0,
        "_ignored" : [
          "name"
        ],
        "_source" : {
          "name" : "12345678901"
        }
      }
    ]
  }
}
举报

相关推荐

0 条评论