Search code examples
jsonuploadwatsonwatson-discovery

Error in uploading JSON documents to Watson Discovery service


I am trying to upload JSON documents to Watson Discovery Service through the POST /documents API. The status code in the response is 202 which means that the document is accepted. But when I check in the Discovery Tooling, the error shown is:

"Error during indexing. The document contains a field type that is different than one with the same name in other documents."

What does this error mean? All the documents have the same fields & format. Some documents might have a few fields missing. I have also tried to upload this document using Discovery tooling, it still gives the same error. Are there any specific things that are checked during indexing JSON documents?


Solution

  • This usually happens when a document indexed has a different type in one or more fields than the document you want to index.

    if you indexed the document below into your collection:

    {
      "id": "doc1",
      "text": "Some text here"
    }
    

    And then tried to index the following document into the same collection:

    {
      "id": "doc2",
      "text": {
        "description": "Some description"
      }
    }
    

    You'll get the error you mentioned above about the text field because one is a string and the other an object.

    Getting an initial 202 is for the acceptance of the document itself. Validation of the compatibility of the final document with the collection happens later because the user can have configurations to normalize/delete fields that would cause conflicts with the existing collection.

    "Missing" fields are fine for indexing.