问题解决:“Cannot search on field [show_num] since it is not indexed.

找的解决方案,因为索引字段已经有数据

1. 新建索引,将mappings的show_num字段,index设置为true

2. 将旧索引的数据,复制到新索引

3. 删除旧索引

没采用新建索引,使用新增字段解决

1. 查询mapping,检测里边是否有需要新增的字段,没有再去新增

URL:http://IP/test_log_20240710-0/_mapping

请求方式:GET

2. 新建字段,index设置为true

新建/更新mapping字段

URL:http://IP/test_log_20240710-0/_mapping

请求方式:PUT

参数:

{
  "properties": {
    "show_num_indexed": {
      "type": "long",
      "index": true,
      "doc_values": false
    }
  }
}

 3. 将不能做查询的旧字段数据,赋值给新字段

将某个字段的值,赋值给新字段

URL:http://IP/test_log_20240710-0/_update_by_query

请求方式:POST

参数:

{
  "script": {
    "source": "ctx._source.show_num_indexed = ctx._source.show_num"
  }
}

4. 使用新字段做查询即可

 {
    "size": 10,
    "query": {
        "bool": {
            "must": [
                {
                    "term": {
                        "status": 200
                    }
                },
                {
                    "term": {
                        "show_num_indexed": 12345
                    }
                }
            ]
        }
    }
}

相关推荐

  1. XML 解析异常问题解决

    2024-07-11 11:20:02       28 阅读
  2. Edge问题解决教程

    2024-07-11 11:20:02       56 阅读
  3. 问题解决记录-pypcd

    2024-07-11 11:20:02       56 阅读
  4. 问题解决方案

    2024-07-11 11:20:02       58 阅读
  5. 20240208问题解决

    2024-07-11 11:20:02       45 阅读
  6. 解决toFixed精度问题

    2024-07-11 11:20:02       45 阅读
  7. 解决跨域问题

    2024-07-11 11:20:02       41 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-07-11 11:20:02       67 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-07-11 11:20:02       72 阅读
  3. 在Django里面运行非项目文件

    2024-07-11 11:20:02       58 阅读
  4. Python语言-面向对象

    2024-07-11 11:20:02       69 阅读

热门阅读

  1. 华为机试HJ84统计大写字母个数

    2024-07-11 11:20:02       20 阅读
  2. MySQL中in和exists的区别

    2024-07-11 11:20:02       20 阅读
  3. Spring Boot 常用 Starter

    2024-07-11 11:20:02       22 阅读
  4. dify/api/models/tool.py文件中的数据表

    2024-07-11 11:20:02       22 阅读
  5. 【SQL】InnoDB的意向锁

    2024-07-11 11:20:02       24 阅读
  6. SpringSecurity中文文档(Servlet OAuth 2.0 Client)

    2024-07-11 11:20:02       19 阅读
  7. Linux串口设备的使用<ubuntu>

    2024-07-11 11:20:02       21 阅读
  8. 计算机如何学习

    2024-07-11 11:20:02       19 阅读
  9. 【通信原理】matlab中pskmod的介绍

    2024-07-11 11:20:02       18 阅读
  10. Perl词法分析:构建编程语言解析器的指南

    2024-07-11 11:20:02       24 阅读