1

我正在尝试使用 More Like This 查询在 Elasticsearch 中获取类似的文档。有一段时间我有一个可行的解决方案,但从那以后文档结构发生了变化,我们现在每个文档都有一个父级。我找不到任何表明无法使用 MLT 找到子文档的东西,但这就是它的样子。任何人都可以阐明为什么这行不通吗?

我没有收到错误,但结果中只有零个文档

类型

car: {
  _parent: {
    type: "dealer"
  },
  _routing: {
    required: true
  },
  properties: {
    id: {
      type: "string"
    },
    make: {
      type: "string",
      fields: {
        raw: {
          type: "string",
          index: "not_analyzed"
        }
      }
    },
    model: {
      type: "string",
      fields: {
        raw: {
          type: "string",
          index: "not_analyzed"
        }
      }
    },
    modelGroup: {
      type: "string",
      fields: {
        raw: {
          type: "string",
          index: "not_analyzed"
        }
      }
    },
    modelRaw: {
      type: "string",
      analyzer: "model_raw_analyzer"
    },

    fuel: {
      type: "string",
      fields: {
        raw: {
          type: "string",
          index: "not_analyzed"
        }
      }
    },
    gearbox: {
      type: "string",
      fields: {
        raw: {
          type: "string",
          index: "not_analyzed"
        }
      }
    },
    additionalVehicleData: {
      properties: {
        bodyType: {
          type: "string"
        },
        color: {
          type: "string"
        },
        colorGroup: {
          type: "string"
        },
        cylinderVolumeCC: {
          type: "long"
        },
        engineEffectHp: {
          type: "long"
        },
        engineEffectKw: {
          type: "long"
        },
        enviromentClass: {
          type: "string"
        },
        fourWheelDrive: {
          type: "boolean"
        },
        fuels: {
          properties: {
            co2Emissions: {
              type: "double"
            },
            engineEffectKw: {
              type: "long"
            },
            name: {
              type: "string"
            }
          }
        },
        height: {
          type: "long"
        },
        length: {
          type: "long"
        },
        make: {
          type: "string"
        },
        maxSpeed: {
          type: "string"
        },
        noPassangers: {
          type: "long"
        },
        weight: {
          type: "long"
        },
        width: {
          type: "long"
        }
      }
    },
    bodyType: {
      type: "string",
      fields: {
        raw: {
          type: "string",
          index: "not_analyzed"
        }
      }
    },
    equipment: {
      type: "string",
      index_analyzer: "swedish_edge_ngram",
      search_analyzer: "swedish"
    },
    freetextColor: {
      type: "string",
      fields: {
        raw: {
          type: "string",
          index: "not_analyzed"
        }
      }
    }
    /*** MORE PROPERTIES HERE ... ***/
  }
}
dealer: {
  properties: {
   id: {
      type: "string"
    },
    name: {
      type: "string",
      fields: {
        raw: {
          type: "string",
          index: "not_analyzed"
        }
      }
    }
    /*** MORE PROPERTIES HERE ... ***/
  }
}

我之前的查询很简单,如下所示,对我的主索引和 type car,其中 ID8379511是有效的汽车 ID:

{
  "from": 0,
  "size": 10,
  "query": {
    "more_like_this": {
      "ids": ["8348446"],
      "min_term_freq":1,
      "min_doc_freq":1
      }
  }
}

像这样将查询更改为使用“like_text”而不是“ids”是可行的,但这并不是我真正想要的,因为我想要基于以下更多参数查找搜索结果的逻辑car

{
  "from": 0,
  "size": 10,
  "query": {
    "more_like_this": {
      "like_text": "volvo",
      "min_term_freq":1,
      "min_doc_freq":1
      }
  }
}

这里有什么想法吗?

4

0 回答 0