弹性嵌套multi_match异常

时间:2016-03-21 16:55:15

标签: elasticsearch

我创建了一个具有用户定义类型的弹性索引,整个配置和示例数据如下,尝试使用搜索短语查询嵌套在剧集下的所有属性,但会发生异常。 社区可以提供帮助吗?

PUT test

映射

PUT test/_mapping/mytype
{
  "properties": {
    "age": {
      "type": "string"
    },
    "birthdate": {
      "type": "date",
      "format": "yyyy-MM-dd"
    },
    "deathdate": {
      "type": "date",
      "format": "yyyy-MM-dd"
    },
    "deceased": {
      "type": "boolean"
    },
    "documentsignatureid": {
      "type": "integer"
    },
    "episodes": {
      "type": "nested",
      "properties": {
        "activities": {
          "type": "nested",
          "properties": {
            "description": {
              "type": "string"
            },
            "executiondate": {
              "type": "date",
              "format": "date_optional_time"
            },
            "performerspecialty": {
              "type": "string",
              "index": "not_analyzed"
            },
            "type": {
              "type": "string",
              "index": "not_analyzed"
            }
          }
        },
        "administrations": {
          "type": "nested",
          "properties": {
            "activeprincipal": {
              "type": "string"
            },
            "administrationdate": {
              "type": "date",
              "format": "date_optional_time"
            },
            "comercialname": {
              "type": "string"
            },
            "dose": {
              "type": "double"
            },
            "frequency": {
              "type": "integer"
            },
            "medicinecode": {
              "type": "string",
              "index": "not_analyzed"
            }
          }
        },
        "age": {
          "type": "string"
        },
        "agedescription": {
          "type": "string",
          "index": "not_analyzed"
        },
        "ageindays": {
          "type": "integer"
        },
        "backgrounds": {
          "type": "nested",
          "properties": {
            "date": {
              "type": "date",
              "format": "date_optional_time"
            },
            "observation": {
              "type": "string"
            },
            "subtype": {
              "type": "string",
              "index": "not_analyzed"
            },
            "type": {
              "type": "string",
              "index": "not_analyzed"
            }
          }
        },
        "biometrics": {
          "type": "nested",
          "properties": {
            "date": {
              "type": "date",
              "format": "date_optional_time"
            },
            "description": {
              "type": "string"
            },
            "value": {
              "type": "string",
              "index": "not_analyzed"
            }
          }
        },
        "birthdate": {
          "type": "date",
          "format": "yyyy-MM-dd"
        },
        "clinicalnotes": {
          "type": "nested",
          "properties": {
            "date": {
              "type": "date",
              "format": "date_optional_time"
            },
            "observation": {
              "type": "string"
            },
            "specialty": {
              "type": "string"
            },
            "type": {
              "type": "string",
              "index": "not_analyzed"
            }
          }
        },
        "deathdate": {
          "type": "date",
          "format": "yyyy-MM-dd"
        },
        "deceased": {
          "type": "boolean"
        },
        "diagnostics": {
          "type": "nested",
          "properties": {
            "code": {
              "type": "string",
              "index": "not_analyzed"
            },
            "codification": {
              "type": "string",
              "index": "not_analyzed"
            },
            "description": {
              "type": "string"
            },
            "enddate": {
              "type": "date",
              "format": "date_optional_time"
            },
            "startdate": {
              "type": "date",
              "format": "date_optional_time"
            },
            "state": {
              "type": "string",
              "index": "not_analyzed"
            },
            "type": {
              "type": "string",
              "index": "not_analyzed"
            }
          }
        },
        "dietetics": {
          "type": "nested",
          "properties": {
            "date": {
              "type": "date",
              "format": "date_optional_time"
            },
            "type": {
              "type": "string",
              "index": "not_analyzed"
            }
          }
        },
        "episodeid": {
          "type": "string",
          "index": "not_analyzed"
        },
        "episodetype": {
          "type": "string",
          "index": "not_analyzed"
        },
        "examinationrequests": {
          "type": "nested",
          "properties": {
            "anticonceptionmethod": {
              "type": "string",
              "index": "not_analyzed"
            },
            "cancellationreason": {
              "type": "string"
            },
            "clinicalinformation": {
              "type": "string"
            },
            "date": {
              "type": "date",
              "format": "yyyy-MM-dd"
            },
            "documentnumber": {
              "type": "string"
            },
            "duration": {
              "type": "string",
              "index": "not_analyzed"
            },
            "examinformations": {
              "type": "nested",
              "properties": {
                "admstate": {
                  "type": "string",
                  "index": "not_analyzed"
                },
                "anatomicalregion": {
                  "type": "string",
                  "index": "not_analyzed"
                },
                "arscode": {
                  "type": "string",
                  "index": "not_analyzed"
                },
                "blockexternal": {
                  "type": "integer"
                },
                "cancellationmotive": {
                  "type": "string",
                  "index": "not_analyzed"
                },
                "charge": {
                  "type": "string",
                  "index": "not_analyzed"
                },
                "code": {
                  "type": "string",
                  "index": "not_analyzed"
                },
                "documentnumber": {
                  "type": "string",
                  "index": "not_analyzed"
                },
                "executantmechanicalnumber": {
                  "type": "string",
                  "index": "not_analyzed"
                },
                "externalcode": {
                  "type": "string",
                  "index": "not_analyzed"
                },
                "externaldescription": {
                  "type": "string",
                  "index": "not_analyzed"
                },
                "externalexecutionmotive": {
                  "type": "string",
                  "index": "not_analyzed"
                },
                "face": {
                  "type": "string",
                  "index": "not_analyzed"
                },
                "id": {
                  "type": "integer"
                },
                "justification": {
                  "type": "string"
                },
                "laterality": {
                  "type": "string",
                  "index": "not_analyzed"
                },
                "name": {
                  "type": "integer"
                },
                "number": {
                  "type": "integer"
                },
                "observation": {
                  "type": "string"
                },
                "sextante": {
                  "type": "integer"
                },
                "state": {
                  "type": "string",
                  "index": "not_analyzed"
                }
              }
            },
            "executingservicecode": {
              "type": "string"
            },
            "executingservicedescription": {
              "type": "string"
            },
            "extrainformation": {
              "type": "string"
            },
            "factor": {
              "type": "string",
              "index": "not_analyzed"
            },
            "frequency": {
              "type": "string",
              "index": "not_analyzed"
            },
            "harvestdate": {
              "type": "date",
              "format": "yyyy-MM-dd"
            },
            "lastmenstruationdate": {
              "type": "date",
              "format": "yyyy-MM-dd"
            },
            "menopause": {
              "type": "boolean"
            },
            "nottransportable": {
              "type": "string",
              "index": "not_analyzed"
            },
            "number": {
              "type": "string",
              "index": "not_analyzed"
            },
            "observations": {
              "type": "string"
            },
            "priority": {
              "type": "string",
              "index": "not_analyzed"
            },
            "requestdate": {
              "type": "date",
              "format": "yyyy-MM-dd"
            },
            "requesthour": {
              "type": "date",
              "format": "yyyy-MM-dd"
            },
            "requestingmedic": {
              "type": "string"
            },
            "requestingservicecode": {
              "type": "string",
              "index": "not_analyzed"
            },
            "requestingservicedescription": {
              "type": "string"
            },
            "sessions": {
              "type": "integer"
            },
            "state": {
              "type": "string",
              "index": "not_analyzed"
            }
          }
        },
        "gender": {
          "type": "string",
          "index": "not_analyzed"
        },
        "internments": {
          "type": "nested",
          "properties": {
            "internmentdate": {
              "type": "date",
              "format": "date_optional_time"
            },
            "number": {
              "type": "string",
              "index": "not_analyzed"
            },
            "realeasedate": {
              "type": "date",
              "format": "date_optional_time"
            }
          }
        },
        "maritalstatus": {
          "type": "string",
          "index": "not_analyzed"
        },
        "mothername": {
          "type": "string"
        },
        "nacionality": {
          "type": "string",
          "index": "not_analyzed"
        },
        "name": {
          "type": "string"
        },
        "patientid": {
          "type": "string",
          "index": "not_analyzed"
        },
        "patienttype": {
          "type": "string",
          "index": "not_analyzed"
        },
        "prescriptions": {
          "type": "nested",
          "properties": {
            "activeprincipal": {
              "type": "string"
            },
            "comercialname": {
              "type": "string"
            },
            "dose": {
              "type": "double"
            },
            "frequency": {
              "type": "integer"
            },
            "medicinecode": {
              "type": "string",
              "index": "not_analyzed"
            },
            "prescriptiondate": {
              "type": "date",
              "format": "date_optional_time"
            },
            "scope": {
              "type": "string",
              "index": "not_analyzed"
            }
          }
        },
        "sns": {
          "type": "string",
          "index": "not_analyzed"
        },
        "title": {
          "type": "string"
        },
        "uniqueid": {
          "type": "string",
          "index": "not_analyzed"
        }
      }
    },
    "gender": {
      "type": "string",
      "index": "not_analyzed"
    },
    "id": {
      "type": "string",
      "index": "not_analyzed"
    },
    "maritalstatus": {
      "type": "string",
      "index": "not_analyzed"
    },
    "mothername": {
      "type": "string"
    },
    "nacionality": {
      "type": "string",
      "index": "not_analyzed"
    },
    "name": {
      "type": "string"
    },
    "patientid": {
      "type": "string",
      "index": "not_analyzed"
    },
    "patienttype": {
      "type": "string",
      "index": "not_analyzed"
    },
    "sns": {
      "type": "string",
      "index": "not_analyzed"
    },
    "title": {
      "type": "string"
    },
    "uniqueid": {
      "type": "string",
      "index": "not_analyzed"
    }
  }
}

样本文件:

PUT test/mytype/UNMDV%2F000000075
{
  "documentsignatureid": 14706,
  "episodes": [
    {
      "administrations": [],
      "birthdate": "1956-06-07",
      "deceased": false,
      "gender": "F",
      "patientid": "000000075",
      "episodetype": "Consultas",
      "clinicalnotes": [
        {
          "date": "2016-01-25T00:00:00",
          "specialty": "Oncologia",
          "observation": "Dores, etc",
          "type": "NOTAS_PRIV"
        },
        {
          "date": "2016-01-25T00:00:00",
          "specialty": "Oncologia",
          "observation": "Dores, etc",
          "type": "EVOLUCAO"
        }
      ],
      "examinationrequests": [],
      "episodeid": "242546",
      "biometrics": [],
      "agedescription": "59 Anos",
      "diagnostics": [],
      "dietetics": [],
      "maritalstatus": "S",
      "activities": [],
      "backgrounds": [],
      "name": "POLIANA PENHA DE JESUS",
      "mothername": "SOFIA FIGUEIRA",
      "internments": [],
      "patienttype": "UNMDV",
      "prescriptions": [],
      "ageindays": 21835,
      "uniqueid": "209445701",
      "age": "59"
    },
    {
      "administrations": [],
      "birthdate": "1956-06-07",
      "deceased": false,
      "gender": "F",
      "patientid": "000000075",
      "episodetype": "Consultas",
      "clinicalnotes": [],
      "examinationrequests": [],
      "episodeid": "242546",
      "biometrics": [],
      "agedescription": "59 Anos",
      "diagnostics": [],
      "dietetics": [],
      "maritalstatus": "S",
      "activities": [],
      "backgrounds": [],
      "name": "POLIANA PENHA DE JESUS",
      "mothername": "SOFIA FIGUEIRA",
      "internments": [],
      "patienttype": "UNMDV",
      "prescriptions": [],
      "ageindays": 21835,
      "uniqueid": "209445701",
      "age": "59"
    },
    {
      "administrations": [],
      "birthdate": "1956-06-07",
      "deceased": false,
      "gender": "F",
      "patientid": "000000075",
      "episodetype": "Consultas",
      "clinicalnotes": [],
      "examinationrequests": [],
      "episodeid": "242546",
      "biometrics": [],
      "agedescription": "59 Anos",
      "diagnostics": [
        {
          "code": "A689",
          "codification": "CID 10",
          "description": "A68.9 - Febre recorrente NE",
          "startdate": "2016-01-25T00:00:00",
          "type": "DEF"
        }
      ],
      "dietetics": [],
      "maritalstatus": "S",
      "activities": [],
      "backgrounds": [],
      "name": "POLIANA PENHA DE JESUS",
      "mothername": "SOFIA FIGUEIRA",
      "internments": [],
      "patienttype": "UNMDV",
      "prescriptions": [],
      "ageindays": 21835,
      "uniqueid": "209445701",
      "age": "59"
    },
    {
      "administrations": [],
      "birthdate": "1956-06-07",
      "deceased": false,
      "gender": "F",
      "patientid": "000000075",
      "episodetype": "Consultas",
      "clinicalnotes": [
        {
          "date": "2016-01-25T00:00:00",
          "specialty": "Oncologia",
          "observation": "Dores, etc",
          "type": "NOTAS_PRIV"
        },
        {
          "date": "2016-01-25T00:00:00",
          "specialty": "Oncologia",
          "observation": "Dores, etc",
          "type": "EVOLUCAO"
        }
      ],
      "examinationrequests": [],
      "episodeid": "242546",
      "biometrics": [],
      "agedescription": "59 Anos",
      "diagnostics": [],
      "dietetics": [],
      "maritalstatus": "S",
      "activities": [],
      "backgrounds": [],
      "name": "POLIANA PENHA DE JESUS",
      "mothername": "SOFIA FIGUEIRA",
      "internments": [],
      "patienttype": "UNMDV",
      "prescriptions": [],
      "ageindays": 21835,
      "uniqueid": "209445701",
      "age": "59"
    }
  ],
  "uniqueid": "209445701",
  "patientid": "000000075",
  "patienttype": "UNMDV",
  "name": "POLIANA PENHA DE JESUS",
  "gender": "F",
  "birthdate": "1956-06-07",
  "mothername": "SOFIA FIGUEIRA",
  "maritalstatus": "S",
  "deceased": false,
  "age": "59"
}

PUT test/mytype/UNMDV%2F000000046
{
  "documentsignatureid": 14711,
  "episodes": [
    {
      "administrations": [],
      "birthdate": "1970-12-12",
      "deceased": false,
      "gender": "F",
      "patientid": "000000046",
      "episodetype": "Consultas",
      "clinicalnotes": [],
      "examinationrequests": [],
      "episodeid": "242557",
      "biometrics": [],
      "agedescription": "45 Anos",
      "diagnostics": [],
      "dietetics": [],
      "maritalstatus": "D",
      "activities": [],
      "backgrounds": [],
      "name": "JURACI IZABEL BADKE NEVES",
      "mothername": "A",
      "internments": [],
      "patienttype": "UNMDV",
      "prescriptions": [],
      "ageindays": 16534,
      "uniqueid": "209442701",
      "age": "45"
    }
  ],
  "uniqueid": "209442701",
  "patientid": "000000046",
  "patienttype": "UNMDV",
  "name": "JURACI IZABEL BADKE NEVES",
  "gender": "F",
  "birthdate": "1970-12-12",
  "mothername": "A",
  "maritalstatus": "D",
  "deceased": false,
  "age": "45"
}

查询:

 POST test/mytype/_search
    {
      "from": 0,
      "size": 20,
      "highlight": {
        "fields": {
          "_all": {}
        },
        "require_field_match": false
      },
      "query": {
        "nested": {
          "path": "episodes",
          "query": {
            "multi_match": {
              "query": "febre",
              "operator": "and",
              "fields": [
                "episodes.*"
              ]
            }
          }
        }
      }
    }

结果:

{
   "error": {
      "root_cause": [
         {
            "type": "illegal_argument_exception",
            "reason": "Invalid format: \"febre\""
         }
      ],
      "type": "search_phase_execution_exception",
      "reason": "all shards failed",
      "phase": "query",
      "grouped": true,
      "failed_shards": [
         {
            "shard": 0,
            "index": "test",
            "node": "W0tautNcT22Z4LNnd5gDCg",
            "reason": {
               "type": "illegal_argument_exception",
               "reason": "Invalid format: \"febre\""
            }
         }
      ]
   },
   "status": 400
}

0 个答案:

没有答案