Uploaded image for project: 'Apache NiFi'
  1. Apache NiFi
  2. NIFI-6458

ElasticSearchClientServiceImpl does not support Elasticserch 7 due to changes in search responses

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Minor
    • Resolution: Fixed
    • 1.9.2
    • None
    • Core Framework, Extensions
    • None
    • NiFi 1.9.2, Elasticsearch 7.1.1

    Description

      Due to the changes in Elasticsearch 7, now it returns a map, not Integer (see 'total.value' in the elastic 7 response), but the code in ElasticSearchClientServiceImpl.java expects to process an integer.
      line 264:
      int count = (Integer)hitsParent.get("total");
      Elastic 7 response example:
      {
      "_shards": ...
      "timed_out": false,
      "took": 100,
      "hits": {
      "max_score": 1.0,
      "total" :

      { "value": 2048, "relation": "eq" }

      ,
      "hits": ...
      }
      }

      Elastic 6 response example:

      { "took" : 63, "timed_out" : false, "_shards" : \{ "total" : 5, "successful" : 5, "skipped" : 0, "failed" : 0 }

      ,
      "hits" : {
      "total" : 1000,
      "max_score" : null,
      "hits" : [ {
      ...

      Therefore, the method of ElasticSearchClientServiceImpl search(String query, String index, String type) throws the following exception:
      java.lang.ClassCastException: java.util.LinkedHashMap cannot be cast to java.lang.Integer: java.lang.ClassCastException: java.util.LinkedHashMap cannot be cast to java.lang.Integer

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              y.sergeev Yury Sergeev
              Votes:
              1 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - 1h
                  1h
                  Remaining:
                  Remaining Estimate - 1h
                  1h
                  Logged:
                  Time Spent - Not Specified
                  Not Specified