Ich versuche ElasticSearch zu bekommen, um an meiner Box zu arbeiten. Ich habe die folgende Abbildung:Abfrage DSL elasticsearch funktioniert nicht
{
"sneakers" : {
"mappings" : {
"sneaker" : {
"properties" : {
"brand" : {
"type" : "nested",
"properties" : {
"id" : {
"type" : "integer",
"index" : "no"
},
"title" : {
"type" : "string"
}
}
}
}
}
}
}
}
So habe ich einen ‚Turnschuh‘ Index mit einem ‚Sneaker‘ Typ, mit einer ‚Marke‘ Eigenschaft, die ein ‚id‘ und ‚title‘ hat.
Überprüfen, dass Turnschuhe existieren, laufen curl -XGET 'http://localhost:9200/sneakers/sneaker/1?pretty', die ich erhalten:
{
"_index" : "sneakers",
"_type" : "sneaker",
"_id" : "1",
"_version" : 1,
"found" : true,
"_source" : {
"brand" : {
"id" : 1,
"title" : "Nike"
}
}
}
Nun runningcurl -XGET 'http://localhost:9200/sneakers/_search?q=brand.title=adidas&pretty' ich:
{
"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"
}
}
}, ...
}
Aber sobald Ich fange an, die Query DSL als solche zu verwenden:
curl -XGET 'http://localhost:9200/sneakers/_search?pretty' -d '{
"query" : {
"term" : { "brand.title" : "adidas" }
}
}
'
Ich bekomme
{
"took" : 9,
"timed_out" : false,
"_shards" : {
"total" : 5,
"successful" : 5,
"failed" : 0
},
"hits" : {
"total" : 0,
"max_score" : null,
"hits" : [ ]
}
}
Irgendwie gibt Query DSL nichts zurück, selbst die einfachsten Abfragen ausgeführt. Ich betreibe ES 2.3.1.
Irgendeine Idee, warum Query DSL nicht funktioniert? Was mache ich falsch?
"Typ" entfernt: "verschachtelt" aus Zuordnungen, funktioniert jetzt einwandfrei. Prost. – Inigo
Super, froh, dass es geholfen hat! – Val