Search code examples
ibm-watsonwatson-discovery

Discovery does not allow nullable date field to be indexed


I am trying to index JSON data in discovery. The issue comes with a date fields. It seems like that discovery is sensing data types. In my case these date fields might be empty in some cases. Is there a way to over ride this data type detection in discovery and let it allow only sense as String while indexing. Please clarify. Soumitra


Solution

  • What you can do (well, assuming you have enough control over the JSON), is omit the date field for documents which have no date. For example these two documents will work together in a single Discovery collection.

    {
      "title": "Document With Date",
      "text": "Discovery detects date types to support range queries, sorting and more.",
      "updated": "2018-04-26T10:11:12Z"
    }
    
    {
      "title": "Undated Document",
      "text": "Discovery has no trouble with fields that appear in some documents and not others."
    }