Index Data into Solr Core using Postman

2019-08-22 10:29发布

问题:

I have created a Solr core. Now i want to insert data into it using Postman. Can we do that and how can we insert data to solr core using Postman. Is there any REST API in Apache SOLR which can be directly called from Postman and insert data to Solr Core.

This is my JSON data which i want to insert. I am getting this exception

Exception writing document id 6 to the index; possible analysis error: For input string: \"\"","code":400}}

 [{
      "id":6,
      "AssetId": 123456,
      "Availability": "Up"
   },
   {
         "id":7,
       "AssetId": 223456,
        "Availability": "Up"
    },
   {
         "id":8,
         "AssetId": 987456,
         "Availability": "Up"
    },
   {
          "id":9,
        "AssetId": 122726,
        "Availability": "Up"

     }]

I want to insert this data to my SOLR Core names as asset. But I am getting exception.

回答1:

As you can see in the docs, you should be able to index that directly:

curl -X POST -H 'Content-Type: application/json' 'http://localhost:8983/solr/my_collection/update' --data-binary '
[
 {
"id" : "978-0641723445",
 "cat" : ["book","hardcover"],
 "name" : "The Lightning Thief",
 "author" : "Rick Riordan",
 "series_t" : "Percy Jackson and the Olympians", 
 "sequence_i" : 1,
 "genre_s" : "fantasy",
 "inStock" : true,
 "price" : 12.50,
 "pages_i" : 384
  },
  {
  ...
  }
]'

If you need to further transform the data, you should look into this



标签: solr