• Elasticsearch keyword 中的 ignore_above配置项


    1. ignore_above

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

    Do not index any string longer than this value. Defaults to 2147483647 so that all values would be accepted.

    不会索引大于ignore_above配置值的数据,默认值2147483647字符。注意:动态mappings中自动为256。

    Strings longer than the ignore_above setting will not be indexed or stored. For arrays of strings, ignore_above will be applied for each array element separately and string elements longer than ignore_above will not be indexed or stored

    大于ignore_above设置的字符串将不会被索引或存储。

    注意:

    All strings/array elements will still be present in the _source field, if the latter is enabled which is the default in Elasticsearch.

    默认所有的字符串/数组元素仍然会出现在_source字段中。

    2.测试

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

    1. PUT test_keyword
    2. {
    3. "mappings": {
    4. "properties": {
    5. "name":{
    6. "type":"keyword",
    7. "ignore_above": 10
    8. }
    9. }
    10. }
    11. }

    向索引中写入数据:

    1. PUT test_keyword/_doc/1
    2. {
    3. "name":"1234567890"
    4. }
    5. PUT test_keyword/_doc/2
    6. {
    7. "name":"12345678901"
    8. }

    查询数据,结果如下:

    1. #可以查询到数据结果
    2. GET test_keyword/_search
    3. {
    4. "query":{
    5. "term": {
    6. "name": "1234567890"
    7. }
    8. }
    9. }
    10. #查询不到数据结果
    11. GET test_keyword/_search
    12. {
    13. "query":{
    14. "term": {
    15. "name": "12345678901"
    16. }
    17. }
    18. }

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

    1. GET test_keyword/_search
    2. {
    3. "took" : 1,
    4. "timed_out" : false,
    5. "_shards" : {
    6. "total" : 1,
    7. "successful" : 1,
    8. "skipped" : 0,
    9. "failed" : 0
    10. },
    11. "hits" : {
    12. "total" : {
    13. "value" : 2,
    14. "relation" : "eq"
    15. },
    16. "max_score" : 1.0,
    17. "hits" : [
    18. {
    19. "_index" : "test_keyword",
    20. "_type" : "_doc",
    21. "_id" : "1",
    22. "_score" : 1.0,
    23. "_source" : {
    24. "name" : "1234567890"
    25. }
    26. },
    27. {
    28. "_index" : "test_keyword",
    29. "_type" : "_doc",
    30. "_id" : "2",
    31. "_score" : 1.0,
    32. "_ignored" : [
    33. "name"
    34. ],
    35. "_source" : {
    36. "name" : "12345678901"
    37. }
    38. }
    39. ]
    40. }
    41. }

  • 相关阅读:
    Scratch软件编程等级考试一级——20200620
    前端使用 Konva 实现可视化设计器(6)- 复制粘贴、删除、位置、zIndex调整
    点餐小程序实战教程07-点餐功能开发
    Tableau自学四部曲_Part3:基础图表制作
    【Detectron2】代码库学习-3. 代码结构
    Vuex(十)
    hue实现对hiveserver2 的负载均衡
    vue2 中store 使用
    金九银十,Java 程序员面试历程(附字节,阿里,百度,网易,美团等面经)
    Centos7.6安装FTP
  • 原文地址:https://blog.csdn.net/qq_32020645/article/details/133304784