Document management
    • PDF

    Document management

    • PDF

    Article Summary

    Perform insert (indexing), update, upsert, delete requests for documents. All requests use the POST method, and Domain must be created before performing the request.

    • By default, insert/upsert requests are made for indexing when a document does not exist, a document has been changed, or the dictionary has been changed resulting in a change in indexing.
    • If update_time is specified, actual changes are approved only if it is the same as or more recent than the update_time of the existing document.
    • Use utf-8 for requests.
    • In a single request, insert/upsert/update/delete can be requested all at once.
    • Requests are processed sequentially. (Parallel processing internally without mixing primary keys)
    • Maximum number of documents for uploading at once is 1000/5 MB, and bulk uploads can be done through Object Storage Document management.
    • Must update the auto complete index through auto complete setting and modification request after this request when using the auto complete feature.
    POST https://cloudsearch.apigw.ntruss.com/CloudSearch/real/v1/domain/{name}/document/manage
    

    Requests

    Request parameters

    Parameter nameRequiredTypeService limitsDescription
    nameYesstringExisting Domain name

    Request bodies

    Field nameRequiredTypeService limitsDescription
    requests[]YesArrayDocument request list
    requests[].typeYesstringSelect one from insert, upsert, update, and deleteRequest type definition
    requests[].update_timeNostringyymmddHHMMSS.ssssss
    Example: 170807133300.000000
    Recommended to specify the time the document was changed in the request
    requests[].forceNobooltrue, falseProcess the request unconditionally without comparing changes with the already indexed document and update_time
    requests[].force_hashNobooltrue, falseIgnore changes with the already indexed document and process the request if the update_time is the same or newer compared to the existing document, based on the comparison of update_time only
    requests[].keyNo (Required when requesting update, delete)stringPrimary key of document
    requests[].contentNo (Required when requesting insert, upsert, and update)objectMust include the key corresponding to the main sectionDocument to use for request (Object in the form of a Map with section name as the key and the values mapped to the key as value)

    Responses

    Field nameTypeDescriptionNote
    request_idstringupdate_time value returned by indexeryymmddHHMMSS.ssssss
    Example: 170807133300.000000
    status.codenumberRequest status0: Succeeded, -1: Failed
    status.messagestringError message when failed
    total_document_countnumberNumber of individual requests included in the request

    Response status

    HTTP StatusDesc
    200OK (Request complete)
    200status.code: -1 (Request failed)
    400Bad Request
    401Unauthorized
    403Forbidden
    404Not Found
    500Internal Server Error

    Request type

    The primary key is the KEY section, and the requests with KEY as 1 are processed sequentially and since the requests with KEY as 1 and those with KEY as 2 are not related to each other, they are processed in parallel internally in the example below.

    insert/upsert/delete/update can be bundled in a single request, and requests[x].content key, value pairs are all composed of strings for requested JSON file. (If used as a numeric type in the search engine, it is internally converted from a string to a numeric type.)

    insert requests

    If the document exists, request for indexing if the document has been changed. If the document does not exist, request for indexing. Consider that the document has changed when the morphological analysis has changed due to the modification of the dictionary or the term/document weight has changed.

    When requesting indexing, it is a principle to provide the entire defined document in the content, however, if omitted except for the key defined as the primary key, an empty string is used.

    Section defined as primary key must be included in the content.

    {
       "requests" : [
          {
             "type" : "insert",
             "key": "1",
             "content" :
              {
                "URL": "http://naver.com/bbs/abc.php?bo_table=QnA&wr_id=321651",
                "KEY": "1",
                "ROOT_ID": "732303375144529937",
                "TITLE": "Testing JSONJSONJSONJSONJSONJSONJSONJSON.",
                "DATE": "2012-01-01T00:00:00+0900",
                "BODY_TEXT": "JSONJSONJSONJSONJSONJSONJSONJSON"
              }
          }
      ]
    }
    

    upsert requests

    If the requested document already exists, it merge with the existing document and then operates the same as an insert. If the requested document is a new document, it is simply indexed.

    primary key must be set in a separate key or must be included in the content.

    {
       "requests" : [
          {
             "type" : "upsert",
             "key" : "1",
             "content" :
              {
                "URL": "http://naver.com/bbs/abc.php?bo_table=QnA&wr_id=321651",
                "KEY": "1",
                "ROOT_ID": "732303375144529937",
                "TITLE": "Testing JSONJSONJSONJSONJSONJSONJSONJSON.",
                "DATE": "2012-01-01T00:00:00+0900",
                "BODY_TEXT": "JSONJSONJSONJSONJSONJSONJSONJSON"
              }
          }
      ]
    }
    

    update requests

    Partially update an existing document. If the requested document does not already exist, nothing happens.

    {
       "requests" : [
          {
             "type" : "update",
             "key" : "2",
             "content" :
              {
                "ROOT_ID": "223",
                "DATE": "2017-01-01T00:00:00+0900"
              }
          }
      ]
    }
    

    delete requests

    Delete requested document. If the requested document does not exist, nothing happens.

    {
       "requests" : [
          {
             "type" : "delete",
             "key" : "2"
          }
      ]
    }
    

    Examples

    Request examples - insert

    POST https://cloudsearch.apigw.ntruss.com/CloudSearch/real/v1/domain/car_dev/document/manage
    
    POST /CloudSearch/real/v1/domain/car_dev/document/manage HTTP/1.1
    Host:cloudsearch.apigw.ntruss.com
    Content-Type: application/json
    x-ncp-apigw-signature-v2: cDwtHuQeGmwWyNmwlN6XIGA66zge4iMXvfoDQNna05g=
    x-ncp-apigw-timestamp: 1545817618751
    x-ncp-iam-access-key: teGTwtcSEGA7fu28BGGi
    
    {
      "requests": [
        {
          "type": "insert",
          "content": {
            "docid": "car-10001",
            "brand": "Hyundai",
            "name": "2018 Santa Fe",
            "color": "black",
            "price": "2817",
            "type": "Mid-size"
          }
        },
        {
          "type": "insert",
          "content": {
            "docid": "car-10002",
            "brand": "Hyundai",
            "name": "2018 Grandeur",
            "color": "white",
            "price": "2618"
          }
        }
        ]
    }
    

    Response examples (Common)

    {
      "result": "ok"
    }
    

    Was this article helpful?

    Changing your password will log you out immediately. Use the new password to log back in.
    First name must have atleast 2 characters. Numbers and special characters are not allowed.
    Last name must have atleast 1 characters. Numbers and special characters are not allowed.
    Enter a valid email
    Enter a valid password
    Your profile has been successfully updated.