2017-05-15 5 views
0

私はElasticsearchでjson構造をマップしようとしていますが、何かが間違っているようです。私のWindowsプロンプトからcurlコマンドを起動すると、アンダースコア以外に何も追加されないためです。jsonマッピングをロードできませんElasticsearch

私はこのcurlコマンドを使用

:なぜ私ができる私にはわからない

EDIT

{"mappings": { 
"_default_": { 
    "properties": { 
    "id": { 
     "type": "string" 
    }, 
    "key": { 
     "type": "string" 
    }, 
    "value": { 
     "type": "object", 
     "properties": { 
     "rev": { 
      "type": "string" 
     } 
     } 
    }, 
    "doc": { 
     "type": "object", 
     "properties": { 
     "_id": { 
      "type": "string" 
     }, 
     "_rev": { 
      "type": "string" 
     }, 
     "userID": { 
      "type": "string" 
     }, 
     "conversation_id": { 
      "type": "string" 
     }, 
     "input": { 
      "type": "object", 
      "properties": { 
      "text": { 
       "type": "string" 
      } 
      } 
     }, 
     "output": { 
      "type": "object", 
      "properties": { 
      "text": { 
       "type": "string" 
      } 
      } 
     }, 
     "node_visited": { 
      "type": "string" 
     }, 
     "intents": { 
      "properties": { 
      "intent": { 
       "type": "string" 
      }, 
      "confidence": { 
       "type": "string" 
      } 
      } 
     }, 
     "entities": { 
      "type": "object", 
      "properties": { 
      "entity": { 
       "type": "string" 
      }, 
      "location": { 
       "type": "string" 
      }, 
      "value": { 
       "type": "string" 
      }, 
      "confidence": { 
       "type": "string" 
      } 
      } 
     }, 
     "timestamp": { 
      "type": "date" 
     } 
     } 
    } 
    } 
}}} 

curl -H "Content-Type: application/json" -XPUT http://localhost:9200/technogym -d "{\"mappings\":{\"id\":{\"type\":\"string\"},\"key\":{\"type\":\"string\"},\"value\":{\"type\":\"object\",\"properties\":{\"rev\":{\"type\":\"string\"}}},\"doc\":{\"type\":\"object\",\"properties\":{\"_id\":{\"type\":\"string\"},\"_rev\":{\"type\":\"string\"},\"userID\":{\"type\":\"string\"},\"conversation_id\":{\"type\":\"string\"},\"input\":{\"type\":\"object\",\"properties\":{\"text\":{\"type\":\"string\"}}},\"output\":{\"type\":\"object\",\"properties\":{\"text\":{\"type\":\"string\"}}},\"node_visited\":{\"type\":\"string\"},\"intents\":{\"properties\":{\"intent\":{\"type\":\"string\"},\"confidence\":{\"type\":\"string\"}}},\"entities\":{\"type\":\"object\",\"properties\":{\"entity\":{\"type\":\"string\"},\"location\":{\"type\":\"string\"},\"value\":{\"type\":\"string\"},\"confidence\":{\"type\":\"string\"}}},\"timestamp\":{\"type\":\"date\"}}}}}" 

ここに私のjsonwithマッピングを(ちょうどそれを読みやすくするため)このマッピングをアップロードしないでください。

ありがとうございました。

答えて

1

あなたが好きなタイプ、例えばにあなたのマッピングを適用後、インデックス

curl -XPUT localhost:9200/technogym 
{"acknowledged":true} 

を作成します。 technogym_type

curl -X PUT localhost:9200/technogym/technogym_type/_mapping -d '{ 
    "properties": { 
    "id": { 
     "type": "string" 
    }, 
    "key": { 
     "type": "string" 
    }, 
    "value": { 
     "type": "object", 
     "properties": { 
     "rev": { 
      "type": "string" 
     } 
     } 
    }, 
    "doc": { 
     "type": "object", 
     "properties": { 
     "_id": { 
      "type": "string" 
     }, 
     "_rev": { 
      "type": "string" 
     }, 
     "userID": { 
      "type": "string" 
     }, 
     "conversation_id": { 
      "type": "string" 
     }, 
     "input": { 
      "type": "object", 
      "properties": { 
      "text": { 
       "type": "string" 
      } 
      } 
     }, 
     "output": { 
      "type": "object", 
      "properties": { 
      "text": { 
       "type": "string" 
      } 
      } 
     }, 
     "node_visited": { 
      "type": "string" 
     }, 
     "intents": { 
      "properties": { 
      "intent": { 
       "type": "string" 
      }, 
      "confidence": { 
       "type": "string" 
      } 
      } 
     }, 
     "entities": { 
      "type": "object", 
      "properties": { 
      "entity": { 
       "type": "string" 
      }, 
      "location": { 
       "type": "string" 
      }, 
      "value": { 
       "type": "string" 
      }, 
      "confidence": { 
       "type": "string" 
      } 
      } 
     }, 
     "timestamp": { 
      "type": "date" 
     } 
     } 
    } 
    } 
}' 

{"acknowledged":true} 

しかし、あなたは動的インデックスとマッピングを作成したい場合は、ちょうどそれがmappings(複数)を必要とし、あなたが望むタイプの名前に続いて、あなたのJSONドキュメントを修正。 (RDBMSテーブル名に相当するタイプ)

curl -X PUT localhost:9200/technogym1 -d ' 
{ 
    "mappings": { 
    "technogym_type1": { 
     "properties": { 
     "id": { 
      "type": "string" 
     }, 
     "key": { 
      "type": "string" 
     }, 
     "value": { 
      "type": "object", 
      "properties": { 
      "rev": { 
       "type": "string" 
      } 
      } 
     }, 
     "doc": { 
      "type": "object", 
      "properties": { 
      "_id": { 
       "type": "string" 
      }, 
      "_rev": { 
       "type": "string" 
      }, 
      "userID": { 
       "type": "string" 
      }, 
      "conversation_id": { 
       "type": "string" 
      }, 
      "input": { 
       "type": "object", 
       "properties": { 
       "text": { 
        "type": "string" 
       } 
       } 
      }, 
      "output": { 
       "type": "object", 
       "properties": { 
       "text": { 
        "type": "string" 
       } 
       } 
      }, 
      "node_visited": { 
       "type": "string" 
      }, 
      "intents": { 
       "properties": { 
       "intent": { 
        "type": "string" 
       }, 
       "confidence": { 
        "type": "string" 
       } 
       } 
      }, 
      "entities": { 
       "type": "object", 
       "properties": { 
       "entity": { 
        "type": "string" 
       }, 
       "location": { 
        "type": "string" 
       }, 
       "value": { 
        "type": "string" 
       }, 
       "confidence": { 
        "type": "string" 
       } 
       } 
      }, 
      "timestamp": { 
       "type": "date" 
      } 
      } 
     } 
     } 
    } 
    } 
}' 
{"acknowledged":true,"shards_acknowledged":true} 
+1

ありがとう;)。はい私は右のjsonで編集しました。なぜなら私の右のものには "マッピング"の代わりに "マッピング"があるからです。助けてくれてありがとう、それはとても役に立ちました –

+1

それはあなたのために働いた素晴らしい。最初に索引(RDBMSのデータベース名と同じ)を作成してからマッピングをタイプしたい場合は、最初に答えてください。それ以外の場合は、実行方法も正しいです。 'http:// localhost:9200/technogym1/technogym_type1/_mapping?pretty = true'でマッピングを確認できます。 – prayagupd

1

mappingmappingsに変更する必要があります。

{ 
"mappings": {    ==> change this 
"_default_": { 
"properties": { 
"id": { 
    "type": "string" 
}, 
"key": { 
    "type": "string" 
}, 
"value": { 
    "type": "object", 
    "properties": { 
    "rev": { 
     "type": "string" 
    } 
    } 
}, 
"doc": { 
    "type": "object", 
    "properties": { 
    "_id": { 
     "type": "string" 
    }, 
    "_rev": { 
     "type": "string" 
    }, 
    "userID": { 
     "type": "string" 
    }, 
    "conversation_id": { 
     "type": "string" 
    }, 
    "input": { 
     "type": "object", 
     "properties": { 
     "text": { 
      "type": "string" 
     } 
     } 
    }, 
    "output": { 
     "type": "object", 
     "properties": { 
     "text": { 
      "type": "string" 
     } 
     } 
    }, 
    "node_visited": { 
     "type": "string" 
    }, 
    "intents": { 
     "properties": { 
     "intent": { 
      "type": "string" 
     }, 
     "confidence": { 
      "type": "string" 
     } 
     } 
    }, 
    "entities": { 
     "type": "object", 
     "properties": { 
     "entity": { 
      "type": "string" 
     }, 
     "location": { 
      "type": "string" 
     }, 
     "value": { 
      "type": "string" 
     }, 
     "confidence": { 
      "type": "string" 
     } 
     } 
    }, 
    "timestamp": { 
     "type": "date" 
     } 
     }}}}}} 
+0

申し訳ありませんが、私は間違ったjsonを投稿しましたが、私の右側にはマッピングがあります。今私は質問を編集する。おかげで –

関連する問題