【问题标题】:Why one of the field of response has "_id" field's value?为什么响应字段之一具有“_id”字段的值?
【发布时间】:2018-11-26 12:24:21
【问题描述】:

我正在开发 Elasticsearch Java API,但遇到了奇怪的问题。

下面是存储的数据:

"_index": "my_index",
"_type": "SEC",
"_id": "1111111111111111",
"_score": 0,
"_source": {
  "LOG_NO": 2222222222222222
}

我将请求称为如下:

QueryBuilder queryBuilder = QueryBuilders.boolQuery().filter(query);
request.setQuery(queryBuilder);
SearchResponse searchResponse = request.get();

这是搜索响应:

"_index":"my_index",
"_type":"SEC",
"_id":"1111111111111111",
"_score":null,
"_source": {
    "LOG_NO":1111111111111111,
}

如您所见,响应的“LOG_NO”应该是“2222222222222222”而不是“1111111111111111”。

参数'query'是QueryBuilder,值如下:

{
  "bool": {
    "must": [
      {
        "range": {
          "LOG_GEN_TIME": {
            "from": "2018-11-01 00:00:00+09:00",
            "to": "2018-11-01 23:59:59+09:00",
            "include_lower": true,
            "include_upper": true,
            "boost": 1
          }
        }
      },
      {
        "bool": {
          "must": [
            {
              "term": {
                "ASSET_IP": "xx.xxx.xxx.xxx"
              }
            },
            {
              "term": {
                "DST_PORT": "xx"
              }
            }
          ]
        }
      }
    ],
    "adjust_pure_negative": true,
    "boost": 1
  }
}

我不明白是什么问题。

任何 cmets 将不胜感激,谢谢。

-- 为@Val 编辑

    "_index": "my_index",
    "_type": "SEC",
    "_id": "9197340043548295192",
    "_score": null,
    "_source": {
      "ASSET_IP": "xx.xxx.xx.xxx",
      "LOG_NO": 9197340043548295200,
      "LOG_GEN_TIME": "2018-11-01 23:10:53+09:00",
      "SRC_IP": "xx.xxx.xx.xxx",
      "SRC_PORT": xx,
      "DST_IP": "xx.xxx.xx.xxx",
      "DST_PORT": xx,
      "DESCRIPTION": "log",
      "DST_NATION_CD": "USA",
    }
  }

这是我希望返回的完整文档,唯一的“LOG_NO”字段有问题。

【问题讨论】:

  • 您能显示您发送的查询以及发送方式吗?
  • @Val 添加了参数查询,我不确定“你如何发送它”的确切含义
  • 感谢您的查询,您能否显示您希望查询返回的完整文档(即不仅是 LOG_NO 字段)?
  • @Val 添加了完整的文档,很抱歉回复晚了 :)
  • 发现了我的问题。谢谢你帮助我@Val

标签: java elasticsearch


【解决方案1】:

我发现问题是javascript。

因为JS不能表达超出数字范围的参数,所以被转换了。

我的 ES 设置是整数字段“LOG_NO”设置为索引,“_id”是“LOG_NO”的字符串表达式。

所以没有问题,只是整数在网络上看起来不一样。

希望其他人不会遇到同样的问题。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-08-02
    • 2012-10-10
    • 2012-07-19
    • 2010-10-26
    • 1970-01-01
    • 2018-11-16
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多