我一直在尝试搜索包含嵌套字段的文档.我创建了这样的嵌套映射:
{
"message": {
"properties": {
"messages": {
"type": "nested",
"properties": {
"message_id": { "type": "string" },
"message_text": { "type": "string" },
"message_nick": { "type": "string" }
}
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
我的搜索看起来像这样:
curl -XGET 'localhost:9200/thread_and_messages/thread/_search' \
-d '{"query": {"bool": {"must": [{"match": {"thread_name": "Banana"}}, {"nested": {"path": "messages", "query": {"bool": {"must": [{"match": {"messages.message_text": "Banana"}}]}}}]}}}}'
Run Code Online (Sandbox Code Playgroud)
然而,我收到此错误消息:
QueryParsingException[[thread_and_messages] [nested] nested object under path [messages] is not of nested type]
Run Code Online (Sandbox Code Playgroud)
编辑
我仍然收到此错误.我通过Java这样做,所以这是我想要创建的文档:
{
"_id": {
"path": "3",
"thread_id": "3",
"thread_name": "Banana",
"created": "Wed Mar …Run Code Online (Sandbox Code Playgroud)