amazon-web-servicesamazon-cloudsearch

How to upload JSON to AWS CloudSearch


It seems like I am missing some pretty simple things, but I can't figure out what's a problem here. I want to upload the JSON file which is next:

[{
    "name": "Mark"
}]

After creating an Index field name: enter image description here

Then I pick Upload Documents on a Dashboard page: enter image description here

And then I have an error:

Your upload includes 1 document containing the following fields: content content_encoding content_type resourcename

enter image description here

What am I doing wrong?


Solution

  • I am currently trying to use it and I have the same problem.

    Try this :

    1/ Create a JSON batch to add your data to your search domain

    For example :

    [
      {
        "type": "add",
        "id": "uniqueid:1",
        "fields": {
            "name": "jack",
        }
      },
      {
        "type": "add",
        "id": "uniqueid:2",
        "fields": {
            "name": "pierre",
        }
      },
      {
        "type": "add",
        "id": "uniqueid:3",
        "fields": {
            "name": "bob",
        }
      }
    ]
    

    2/ Now go to your domains dashboard and click "upload document" : upload this JSON batch

    3/ Go to "run a test search" and try to find "bob" for example : you should have your bob data !

    The documentation about the batch : https://docs.aws.amazon.com/cloudsearch/latest/developerguide/preparing-data.html

    To upload data to your search domain you need to respect this batch format, look the documentation and the guidelines :)

    You can do it too using a bucket that will be use to trigger a lambda function, the idea is : when you will upload a file in the bucket, launch your lambda function to read this file and create a batch file that will add the new data to your index. And when you remove a file : you delete the data to your index !

    Look this tutorial if you need some help with the lambda function : https://medium.com/devopslinks/build-your-own-document-search-engine-using-amazon-web-services-82d5b165d96c

    Hope it helps !