0
我試圖讓ElasticSearch在我的盒子上工作。我有以下映射:查詢DSL elasticsearch不起作用
{
"sneakers" : {
"mappings" : {
"sneaker" : {
"properties" : {
"brand" : {
"type" : "nested",
"properties" : {
"id" : {
"type" : "integer",
"index" : "no"
},
"title" : {
"type" : "string"
}
}
}
}
}
}
}
}
所以我有一個「鞋」指數以「運動鞋」型,與具有「身份證」和「標題」一個「品牌」屬性。
檢查球鞋存在,運行卷曲-XGET 'http://localhost:9200/sneakers/sneaker/1?pretty',我得到:
{
"_index" : "sneakers",
"_type" : "sneaker",
"_id" : "1",
"_version" : 1,
"found" : true,
"_source" : {
"brand" : {
"id" : 1,
"title" : "Nike"
}
}
}
現在,runningcurl -XGET 'http://localhost:9200/sneakers/_search?q=brand.title=adidas&pretty' 我得到:
{
"took" : 13,
"timed_out" : false,
"_shards" : {
"total" : 5,
"successful" : 5,
"failed" : 0
},
"hits" : {
"total" : 1330,
"max_score" : 0.42719018,
"hits" : [ {
"_index" : "sneakers",
"_type" : "sneaker",
"_id" : "19116",
"_score" : 0.42719018,
"_source" : {
"brand" : {
"id" : 2,
"title" : "Adidas"
}
}
}, ...
}
但只要我開始使用Query DSL:
curl -XGET 'http://localhost:9200/sneakers/_search?pretty' -d '{
"query" : {
"term" : { "brand.title" : "adidas" }
}
}
'
我得到
{
"took" : 9,
"timed_out" : false,
"_shards" : {
"total" : 5,
"successful" : 5,
"failed" : 0
},
"hits" : {
"total" : 0,
"max_score" : null,
"hits" : [ ]
}
}
不知何故查詢DSL從不返回任何內容,甚至運行最簡單的查詢。我正在運行ES 2.3.1。
任何想法是爲什麼查詢DSL不工作?我究竟做錯了什麼?
從映射中刪除「類型」:「嵌套」,現在完美工作。乾杯。 – Inigo
太棒了,很高興幫助! – Val