0

我刚开始使用 ElasticSearch,并且已经设法进行基本查询等,但现在我有一个像这样的数据映射:

merchant: {
  properties: {
    id: {
      type: 'integer'
    },
    name: {
      type: 'text'
    },
    logo: {
      type: 'boolean'
    }
  }
},
store: {
  properties: {
    location: {
      type: 'geo_point'
    },
    category: {
      type: 'integer'
    }
  }
}

我正在尝试根据与文档距离排序示例的距离对结果进行排序。现在我无法弄清楚如何使它与 store 下的 location 字段一起工作。使用store.location会产生如下错误:

{
  "error" : {
    "root_cause" : [
      {
        "type" : "parsing_exception",
        "reason" : "unknown field [store.location]",
        "line" : 1,
        "col" : 0
      }
    ],
    "type" : "search_phase_execution_exception",
    "reason" : "all shards failed",
    "phase" : "query",
    "grouped" : true,
    "failed_shards" : [
      {
        "shard" : 0,
        "index" : "merchants",
        "node" : "9t4Z6koOTe2rWZmNcwYNNQ",
        "reason" : {
          "type" : "parsing_exception",
          "reason" : "unknown field [store.location]",
          "line" : 1,
          "col" : 0
        }
      }
    ]
  },
  "status" : 400
}

我找不到什么可以使它起作用store.location

{
    "merchants" => {
        "mappings" => {
            "store" => {
                "properties" => {
                    "category" => {
                        "type" => "integer"
                    }, "location" => {
                        "type" => "geo_point"
                    }
                }
            }, "merchant" => {
                "properties" => {
                    "id" => {
                        "type" => "integer"
                    }, "logo" => {
                        "type" => "boolean"
                    }, "name" => {
                        "type" => "text"
                    }
                }
            }, "offer" => {
                "properties" => {
                    "description" => {
                        "type" => "text"
                    }, "expiresAt" => {
                        "type" => "integer"
                    }, "id" => {
                        "type" => "integer"
                    }, "intro" => {
                        "type" => "text"
                    }, "title" => {
                        "type" => "text"
                    }, "top" => {
                        "type" => "integer"
                    }
                }
            }
        }
    }
}
4

0 回答 0