Schritt 1: http://localhost:9200/shop/_mapping/clothElastic Abfrage Verschachtelte Abfrage
HTTP/1.1 200 OK Content-Type:
einen Index für Elasticsearch http://localhost:9200/shop mit unter mapping.json
{
"cloth" :
{
"properties" :
{
"name" : { "type" : "string", "index" : "analyzed" },
"variation" :
{
"type" : "nested",
"properties" :
{
"size" :
{
"type" : "string", "index" : "not_analyzed"
},
"color" :
{
"type" : "string", "index" : "not_analyzed"
}
}
}
}
}
}
GET Erstellt : Anwendung/JSON; charset = UTF-8 Content-Length: 518
{ "shop": { "Mappings": { "Tuch": { "Eigenschaften": { "Tuch": { "Eigenschaften": { "Eigenschaften": {"Eigenschaften": {"Name": {"Eigenschaften": {"Index": {"Typ": "Zeichenkette"}, "Typ": {"Typ": "Zeichenkette"}}}, "Variation": {"Eigenschaften": {"Eigenschaften": {"Eigenschaften": {"Farbe": {"Eigenschaften": {"Index": {"Typ": "Zeichenkette"}, "Typ": {"Typ": "" String "}}}," Größe ": {" Eigenschaften ": {" Index ": {" Typ ":" String "}," Typ ": {" Typ ":" String "}}}}," Typ ": {" type ":" string "}}}}}}}," name ": {" type ":" string "}," variation ": {" Eigenschaften ": {" color ": {" type " : "string"}, "Größe": { "type": "string"}}}}}}}}
Schritt 2:
die Daten eingefügt mit unten angegebenen data.j Sohn http://localhost:9200/shop/cloth/?_create
{
"name" : "Test shirt",
"variation" : [
{ "size" : "XXL", "color" : "red" },
{ "size" : "XL", "color" : "black" }
]
}
Schritt 3:
mit bestimmten query.json
http://localhost:9200/shop/cloth/_search
{
"query" : {
"nested" : {
"path" : "variation",
"query" : {
"bool" : {
"must" : [
{ "term" : { "variation.size" : "XXL" } },
{ "term" : { "variation.color" : "black" } }
]
}
}
}
}
}
Suche Versuchte
Unten Fehler folgt
HTTP/1.1 400 Bad Request Inhaltstyp: application/json; charset = UTF-8 Content-Length: 519
{"error":{"root_cause":[{"type":"query_parsing_exception","reason":"[nested] nested object under path [variation] is not of nested type","index":"shop","line":4,"col":1}],"type":"search_phase_execution_exception","reason":"all shards failed","phase":"query","grouped":true,"failed_shards":[{"shard":0,"index":"shop","node":"6U9SA_SDRJKfw1bRxwH8ig","reason":{"type":"query_parsing_exception","reason":"[nested] nested object under path [variation] is not of nested type","index":"shop","line":4,"col":1}}]},"status":400}
Was ist der Weg zu suchen, mit Abfragen verschachtelt? Gibt es eine geeignete Methode zum Laden der Zuordnungsdatei in den Such-Cluster?
Können Sie Ihre Frage mit dem Ausgang Sie Formular get update 'curl -XGET localhost: 9200/shop/_mapping/cloth'? – Val
Wie wir das Mapping einfügen können, wie es als POST mit Mapping.json Inhalt –
mein schlechtes tut, tut mir leid, bitte überprüfen Sie meine obigen Kommentar erneut. – Val