3
我有很多在Elasticsearch嵌套類型的映射問題
不,我已經跑這來創建我的索引:Elasticsearch:下路[消息]嵌套的對象是嵌套類型
curl -XPOST 'http://localhost:9200/thread_and_messages' -d
'{"mappings" : {
"message": {
"properties": {
"messages": {
"type": "nested",
"include_in_parent": true,
"properties": {
"message_id": {"type": "string"},
"message_text": {"type": "string"},
"message_nick": {"type": "string"}
}
}
}
}
}}'
那麼這如何我已經索引的文檔:
curl -XPUT 'http://localhost:9200/thread_and_messages/thread/1' -d
'{
"thread_id":"2",
"thread_name":"Windows",
"created":"Wed Mar 25 2015",
"first_nick":"Admin",
"messages":[
{"message_id":"5", "message_text":" Pc with a mouse", "message_nick":"Admin"},
{"message_id":"6", "message_text":"Keyboard", "message_nick":"Admin"},
{"message_id":"7", "message_text":"iPhone", "message_nick":"Admin"},
{"message_id":"8", "message_text":"Gym", "message_nick":"Admin"}]"
}'
這是我的查詢:
curl -XGET 'http://localhost:9200/thread_and_messages/thread/_search' -d
'{"query": {
"bool": {
"must": [
{"match": {"thread_name": "windows"}},
{"nested": {
"path": "messages", "query": {
"bool": {
"must": [{
"match": {"messages.message_text": "gym"}
}]
}
}
}}
]}
}
}'
我收到此錯誤,即使我已經清楚地映射消息爲嵌套類型:
QueryParsingException[[thread_and_messages] [nested] nested object under path [messages] is not of nested type