[英]Query DSL elasticsearch doesn't work
我正在嘗試讓ElasticSearch在我的盒子上工作。 我有以下映射:
{
"sneakers" : {
"mappings" : {
"sneaker" : {
"properties" : {
"brand" : {
"type" : "nested",
"properties" : {
"id" : {
"type" : "integer",
"index" : "no"
},
"title" : {
"type" : "string"
}
}
}
}
}
}
}
}
因此,我有一個“運動鞋”類型的“運動鞋”索引,其“品牌”屬性具有一個“ id”和一個“ title”。
檢查運動鞋是否存在,運行curl -XGET'http :// localhost:9200 / sneakers / sneaker / 1?pretty ',我得到:
{
"_index" : "sneakers",
"_type" : "sneaker",
"_id" : "1",
"_version" : 1,
"found" : true,
"_source" : {
"brand" : {
"id" : 1,
"title" : "Nike"
}
}
}
現在,運行curl -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。
知道為什么Query DSL無法正常工作嗎? 我究竟做錯了什么?
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.