简体   繁体   中英

Solr update with Rest API Json data

I'm using solr 6.5.1. I have json data in Rest url;

For example:

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

I can able to fetch data via postman rest client. Is there anyway to post data to solr collection via above rest post url? Please tell me how do i implement this feature in solr.

Try this:

 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" } 

And if you want to import it into Postman, here's a json (save it to a .json and then import it as a collection into 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": []
    }
]}

For more details, see the solr documentation:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM