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