[英]How to create an Elasticsearch mapping with not_analyzed nested fields?
[英]How to tell ElasticSearch to create nested fields
我將數據放入ES並檢查創建的映射,
我正在執行此操作:
curl -XPOST 'http://localhost:9200/testnested2/type1/0' -d '{
"p1": ["1","2","3","4"],
"users" : {
"first" : "John",
"last" : "Sm11ith"
}
}'
這是它創建的架構:
{
"testnested2":{
"mappings":{
"type1":{
"properties":{
"p1":{"type":"string"},
"users":{
"properties":{
"first":{"type":"string"},
"last":{"type":"string"}
}
}
}
}
}
}
}
我想知道是否可以告訴它“用戶”是嵌套的,還是我必須為自己創建映射。
我希望ES可以像這樣創建一個shema:
curl -XPOST http://180.5.5.93:9200/testnested3 -d '{
"settings" : {
"number_of_shards" : 1
},
"mappings" : {
"type1" : {
"properties" : {
"propiedad1" : { "type" : "string"},
"users" : {
"type" : "nested",
"include_in_parent": true,
"properties": {
"first" : {"type": "string" },
"last" : {"type": "string" }
}
}
}
}
}
}'
默認情況下,ElasticSearch的動態映射功能會將users
映射為object
而不是nested
。
如果要調整此行為,則必須顯式定義一個nested
的users
屬性:
users
屬性將自動設置為nested
(有關默認映射信息,請參見此處 )
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.