【问题标题】:Elasticsearch: How to add nested datatype using Java api?Elasticsearch:如何使用 Java api 添加嵌套数据类型?
【发布时间】:2021-02-07 19:03:29
【问题描述】:

示例::

"price":{  
       "type":"nested",  --> how to add this using java api 
       "properties":{  
          "activity_price":{  
             "type":"double"
          },
          "multimedia_price":{  
             "type":"double"
          },
          "transportation_price":{  
             "type":"double"
          }
       }
    }

其实我想在 mapping.json 中添加 "type" :"nested"
要查找嵌套对象,我使用嵌套查询。但是得到 “[nested] 未能在路径 [...] 下找到嵌套对象”。

感谢您的帮助。

【问题讨论】:

    标签: elasticsearch elastic-stack elasticsearch-5 elasticsearch-java-api


    【解决方案1】:
        "nested" : {
          "query" : {
            "bool" : {
              "must" : [
                {
                  "match" : {
                    "price.activity_price" : {
                      "query" : 1.0,
                    }
                  }
                }]
            }
          },
          "path" : "price",
          "ignore_unmapped" : false,
          "score_mode" : "none",
          "boost" : 1.0
        }
    

    这就是嵌套查询的方式。最后错误已经消失并返回了预期的结果。

    【讨论】:

      猜你喜欢
      • 2018-02-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-08-31
      • 2013-06-27
      • 1970-01-01
      相关资源
      最近更新 更多