使用Rest API Json数据进行Solr更新

时间:2017-05-23 10:44:34

标签: json postgresql rest solr

我使用solr 6.5.1。我在Rest url中有json数据;

例如:

POST : http://localhost:8484/api/cloud/list-users
       is_user: xxx
       is_key : pqxqxaweqweqx14123

我可以通过邮递员休息客户端获取数据。无论如何通过上面的休息后网址将数据发布到solr集合?请告诉我如何在solr中实现此功能。

1 个答案:

答案 0 :(得分:0)

试试这个:

POST /api/cloud/list-users/update/json/docs?commit=true HTTP/1.1
Host: localhost:8484
Content-Type: application/json

{
"is_user": "xxx",
"is_key": "pqxqxaweqweqx14123"
}

如果你想将它导入Postman,这里是一个json(将它保存到.json然后将其作为集合导入Postman)

{
"variables": [],
"info": {
    "name": "Solr Post New Document",
    "_postman_id": "291f6b0e-6aad-7778-c29d-f194ce45c5de",
    "description": "",
    "schema": "https://schema.getpostman.com/json/collection/v2.0.0/collection.json"
},
"item": [
    {
        "name": "Solr Post New Document",
        "request": {
            "url": "http://localhost:8983/solr/test/update/json/docs?commit=true",
            "method": "POST",
            "header": [
                {
                    "key": "Content-Type",
                    "value": "application/json",
                    "description": ""
                }
            ],
            "body": {
                "mode": "raw",
                "raw": "{\n\"is_user\": \"xxx\",\n\"is_key\": \"pqxqxaweqweqx14123\"\n}\n"
            },
            "description": ""
        },
        "response": []
    }
]}

有关详细信息,请参阅solr文档:

https://cwiki.apache.org/confluence/display/solr/Uploading+Data+with+Index+Handlers#UploadingDatawithIndexHandlers-JSONFormattedIndexUpdates