2016-11-07 15 views
0

我使用PUT命令:Elasticsearch如何索引現有的JSON文件

curl -PUT "http://localhost:9200/music/lyrics/2" --data-binary @D:\simple\caseyjones.json 

caseyjones.json:

{ 
    "artist": "Wallace Saunders", 
    "year": 1909, 
    "styles": ["traditional"], 
    "album": "Unknown", 
    "name": "Ballad of Casey Jones", 
    "lyrics": "Come all you rounders if you want to hear 
      The story of a brave engineer 
      Casey Jones was the rounder's name.... 
      Come all you rounders if you want to hear 
      The story of a brave engineer 
      Casey Jones was the rounder's name 
      On the six-eight wheeler, boys, he won his fame 
      The caller called Casey at half past four 
      He kissed his wife at the station door 
      He mounted to the cabin with the orders in his hand 
      And he took his farewell trip to that promis'd land 

      Chorus: 
      Casey Jones--mounted to his cabin 
      Casey Jones--with his orders in his hand 
      Casey Jones--mounted to his cabin 
      And he took his... land" 
} 

警告:無法解析,文件是空的。但是日誌顯示* .json文件的內容。 Elasticsearch Screenshot

回答

0

JSON不允許換行符。因此,您需要用\ n(特定於平臺)替換所有換行符,並將文本存儲爲一行。

像:

{ 
    "artist": "Wallace Saunders", 
    "year": 1909, 
    "styles": ["traditional"], 
    "album": "Unknown", 
    "name": "Ballad of Casey Jones", 
    "lyrics": "Come all you rounders if you want to hear\nThe story of a brave engineer\nCasey Jones was the rounder's name...." 
} 
+0

仍然有同樣的錯誤... – kevin4z

相關問題