Getting wrong_method_type_exception

Query -

{"timeout":"900000ms","query":{"constant_score":{"filter":{"bool":{"must":{"bool":{"must":[{"bool":{"should":[{"terms":{"addI.sem.data.sentiment_polarity":["-1","-2","-1.0","-2.0","negative"]}},{"terms":{"addI.sem.data.sentiment_polarity":["0","0.0","neutral"]}},{"terms":{"addI.sem.data.sentiment_polarity":["1","2","1.0","2.0","positive"]}}]}},{"terms":{"add.m_t":["BLOGS","NEWS","PRINT","RADIO","TV","WORDPRESS"]}},{"bool":{"must_not":{"bool":{"should":[{"script":{"script":{"inline":"doc['enr.fc.ag'].value != null && Integer.parseInt(doc['enr.fc.ag'].value) >= params.from && Integer.parseInt(doc['enr.fc.ag'].value) < params.to","lang":"painless","params":{"from":0,"to":18}}}},{"script":{"script":{"inline":"doc['enr.fc.ag'].value != null && Integer.parseInt(doc['enr.fc.ag'].value) >= params.from && Integer.parseInt(doc['enr.fc.ag'].value) < params.to","lang":"painless","params":{"from":18,"to":25}}}},{"script":{"script":{"inline":"doc['enr.fc.ag'].value != null && Integer.parseInt(doc['enr.fc.ag'].value) >= params.from && Integer.parseInt(doc['enr.fc.ag'].value) < params.to","lang":"painless","params":{"from":25,"to":35}}}},{"script":{"script":{"inline":"doc['enr.fc.ag'].value != null && Integer.parseInt(doc['enr.fc.ag'].value) >= params.from && Integer.parseInt(doc['enr.fc.ag'].value) < params.to","lang":"painless","params":{"from":35,"to":45}}}},{"script":{"script":{"inline":"doc['enr.fc.ag'].value != null && Integer.parseInt(doc['enr.fc.ag'].value) >= params.from && Integer.parseInt(doc['enr.fc.ag'].value) < params.to","lang":"painless","params":{"from":45,"to":55}}}}]}}}},{"bool":{"must":[{"terms":{"add.m_t":["PRINT","TV","BLOGS","DATA_INGESTION","NEWS","RADIO","WORDPRESS"]}},{"term":{"addI.lstTopic.ord":10165}}],"must_not":{"terms":{"pSens":[true]}},"_cache_key":"bb374d0973b310e8f40f81be338a92f2"}},{"terms":{"iD":[false]}},{"bool":{"must_not":{"terms":{"add.prS":["fac"]}}}}]}},"must_not":[{"bool":{"must_not":{"terms":{"snT":["DATA_INGESTION"]}},"should":[{"bool":{"must":[{"terms":{"fU.sN":["lets_dex","cdnleon","galaxy_boy28"]}},{"term":{"add.m_t":"TWITTER"}}]}},{"term":{"addI.lstTopic.ord":-2}}],"_cache_key":"9d9347375877083bd3bed5f5d0d6ed99"}},{"bool":{"should":[{"bool":{"should":[{"terms":{"add.domain":["1wmb.ru"]}},{"terms":{"add.td":["1wmb.ru"]}}]}},{"terms":{"mVadd.aiT":["hulk_replay"]}}],"_cache_key":"c5da0ea16f8df89ece72fa05f369d702"}}]}}}},"aggregations":{"61a9ca602f0d31e99c690df1":{"filter":{"match_all":{}},"aggregations":{"SN_CREATED_TIME_0":{"date_histogram":{"field":"snCTm","interval":"1d","min_doc_count":1,"time_zone":"Asia/Seoul"},"aggregations":{"M_SPRINKSIGHTS_IM_NEGATIVE_MENTIONS290_1_FILTERED_PROJECTION":{"filter":{"bool":{"must":{"terms":{"addI.mW.pCP._c_61938912e74c3e225a4f004b":["negative"]}}}},"aggregations":{"M_SPRINKSIGHTS_IM_NEGATIVE_MENTIONS290_1":{"calculated3":{"expr":"double M_SPRINKSIGHTS_IM_NEGATIVE_MENTIONS290_1 = ((_C9CD0A6947C39E2534601364472E91D5));return M_SPRINKSIGHTS_IM_NEGATIVE_MENTIONS290_1;","_C9CD0A6947C39E2534601364472E91D5":{"aggregateFunc":"sum","filter":{"bool":{"must":{"terms":{"addI.mW.pCP._c_61938912e74c3e225a4f004b":["negative"]}}}},"script":{"inline":"1"}}}}}},"M_SPRINKSIGHTS_IM_NEUTRAL_MENTIONS344_2_FILTERED_PROJECTION":{"filter":{"bool":{"must":{"terms":{"addI.mW.pCP._c_61938912e74c3e225a4f004b":["neutral"]}}}},"aggregations":{"M_SPRINKSIGHTS_IM_NEUTRAL_MENTIONS344_2":{"calculated3":{"expr":"double M_SPRINKSIGHTS_IM_NEUTRAL_MENTIONS344_2 = ((_BBA9E0EDA7BF2776984506B35CD963D6));return M_SPRINKSIGHTS_IM_NEUTRAL_MENTIONS344_2;","_BBA9E0EDA7BF2776984506B35CD963D6":{"aggregateFunc":"sum","filter":{"bool":{"must":{"terms":{"addI.mW.pCP._c_61938912e74c3e225a4f004b":["neutral"]}}}},"script":{"inline":"1"}}}}}},"M_SPRINKSIGHTS_IM_POSITIVE_MENTIONS715_0_FILTERED_PROJECTION":{"filter":{"bool":{"must":{"terms":{"addI.mW.pCP._c_61938912e74c3e225a4f004b":["positive"]}}}},"aggregations":{"M_SPRINKSIGHTS_IM_POSITIVE_MENTIONS715_0":{"calculated3":{"expr":"double M_SPRINKSIGHTS_IM_POSITIVE_MENTIONS715_0 = ((_F0AED24BB6B7EACF0B91D7AAEBEE19B6));return M_SPRINKSIGHTS_IM_POSITIVE_MENTIONS715_0;","_F0AED24BB6B7EACF0B91D7AAEBEE19B6":{"aggregateFunc":"sum","filter":{"bool":{"must":{"terms":{"addI.mW.pCP._c_61938912e74c3e225a4f004b":["positive"]}}}},"script":{"inline":"1"}}}}}}}}}}},"size":"0"}

Getting

    "error": {
        "root_cause": [
            {
                "type": "wrong_method_type_exception",
                "reason": "wrong_method_type_exception: cannot convert MethodHandle(Longs)long to (Object)String"
            },
            {
                "type": "script_exception",
                "reason": "runtime error",
                "script_stack": [
                    "doc['enr.fc.ag'].value != null && Integer.parseInt(doc['enr.fc.ag'].value) >= params.from && Integer.parseInt(doc['enr.fc.ag'].value) < params.to",
                    "                                                                   ^---- HERE"
                ],
                "script": "doc['enr.fc.ag'].value != null && Integer.parseInt(doc['enr.fc.ag'].value) >= params.from && Integer.parseInt(doc['enr.fc.ag'].value) < params.to",
                "lang": "painless",
                "position": {
                    "offset": 67,
                    "start": 0,
                    "end": 145
                }
            },
            {
                "type": "wrong_method_type_exception",
                "reason": "wrong_method_type_exception: cannot convert MethodHandle(Longs)long to (Object)String"
            },
            {
                "type": "script_exception",
                "reason": "runtime error",
                "script_stack": [
                    "doc['enr.fc.ag'].value != null && Integer.parseInt(doc['enr.fc.ag'].value) >= params.from && Integer.parseInt(doc['enr.fc.ag'].value) < params.to",
                    "                                                                   ^---- HERE"
                ],
                "script": "doc['enr.fc.ag'].value != null && Integer.parseInt(doc['enr.fc.ag'].value) >= params.from && Integer.parseInt(doc['enr.fc.ag'].value) < params.to",
                "lang": "painless",
                "position": {
                    "offset": 67,
                    "start": 0,
                    "end": 145
                }
            },
            {
                "type": "wrong_method_type_exception",
                "reason": "wrong_method_type_exception: cannot convert MethodHandle(Longs)long to (Object)String"
            }
        ],
        "type": "search_phase_execution_exception",
        "reason": "all shards failed",
        "phase": "query",
        "grouped": true,
        "failed_shards": [
            {
                "shard": 0,
                "index": "lst_p124_v_14_20220814_2359",
                "node": "3pnsOw8CQOu9g3m3Vi9lPA",
                "reason": {
                    "type": "script_exception",
                    "reason": "runtime error",
                    "script_stack": [
                        "doc['enr.fc.ag'].value != null && Integer.parseInt(doc['enr.fc.ag'].value) >= params.from && Integer.parseInt(doc['enr.fc.ag'].value) < params.to",
                        "                                                                   ^---- HERE"
                    ],
                    "script": "doc['enr.fc.ag'].value != null && Integer.parseInt(doc['enr.fc.ag'].value) >= params.from && Integer.parseInt(doc['enr.fc.ag'].value) < params.to",
                    "lang": "painless",
                    "position": {
                        "offset": 67,
                        "start": 0,
                        "end": 145
                    },
                    "caused_by": {
                        "type": "wrong_method_type_exception",
                        "reason": "wrong_method_type_exception: cannot convert MethodHandle(Longs)long to (Object)String"
                    }
                }
            },
            {
                "shard": 0,
                "index": "lst_p124_v_14_20220816_2051",
                "node": "i1dLqmGjRbSea8_1SX83Rg",
                "reason": {
                    "type": "script_exception",
                    "reason": "runtime error",
                    "script_stack": [
                        "doc['enr.fc.ag'].value != null && Integer.parseInt(doc['enr.fc.ag'].value) >= params.from && Integer.parseInt(doc['enr.fc.ag'].value) < params.to",
                        "                                                                   ^---- HERE"
                    ],
                    "script": "doc['enr.fc.ag'].value != null && Integer.parseInt(doc['enr.fc.ag'].value) >= params.from && Integer.parseInt(doc['enr.fc.ag'].value) < params.to",
                    "lang": "painless",
                    "position": {
                        "offset": 67,
                        "start": 0,
                        "end": 145
                    },
                    "caused_by": {
                        "type": "wrong_method_type_exception",
                        "reason": "cannot convert MethodHandle(Longs)long to (Object)String"
                    }
                }
            },
            {
                "shard": 0,
                "index": "lst_p124_v_14_20220818_1314",
                "node": "3pnsOw8CQOu9g3m3Vi9lPA",
                "reason": {
                    "type": "script_exception",
                    "reason": "runtime error",
                    "script_stack": [
                        "doc['enr.fc.ag'].value != null && Integer.parseInt(doc['enr.fc.ag'].value) >= params.from && Integer.parseInt(doc['enr.fc.ag'].value) < params.to",
                        "                                                                   ^---- HERE"
                    ],
                    "script": "doc['enr.fc.ag'].value != null && Integer.parseInt(doc['enr.fc.ag'].value) >= params.from && Integer.parseInt(doc['enr.fc.ag'].value) < params.to",
                    "lang": "painless",
                    "position": {
                        "offset": 67,
                        "start": 0,
                        "end": 145
                    },
                    "caused_by": {
                        "type": "wrong_method_type_exception",
                        "reason": "wrong_method_type_exception: cannot convert MethodHandle(Longs)long to (Object)String"
                    }
                }
            },
            {
                "shard": 0,
                "index": "lst_p124_v_14_20220820_0515",
                "node": "i1dLqmGjRbSea8_1SX83Rg",
                "reason": {
                    "type": "script_exception",
                    "reason": "runtime error",
                    "script_stack": [
                        "doc['enr.fc.ag'].value != null && Integer.parseInt(doc['enr.fc.ag'].value) >= params.from && Integer.parseInt(doc['enr.fc.ag'].value) < params.to",
                        "                                                                   ^---- HERE"
                    ],
                    "script": "doc['enr.fc.ag'].value != null && Integer.parseInt(doc['enr.fc.ag'].value) >= params.from && Integer.parseInt(doc['enr.fc.ag'].value) < params.to",
                    "lang": "painless",
                    "position": {
                        "offset": 67,
                        "start": 0,
                        "end": 145
                    },
                    "caused_by": {
                        "type": "wrong_method_type_exception",
                        "reason": "cannot convert MethodHandle(Longs)long to (Object)String"
                    }
                }
            },
            {
                "shard": 0,
                "index": "lst_p124_v_14_20220822_1343",
                "node": "3pnsOw8CQOu9g3m3Vi9lPA",
                "reason": {
                    "type": "script_exception",
                    "reason": "runtime error",
                    "script_stack": [
                        "doc['enr.fc.ag'].value != null && Integer.parseInt(doc['enr.fc.ag'].value) >= params.from && Integer.parseInt(doc['enr.fc.ag'].value) < params.to",
                        "                                                                   ^---- HERE"
                    ],
                    "script": "doc['enr.fc.ag'].value != null && Integer.parseInt(doc['enr.fc.ag'].value) >= params.from && Integer.parseInt(doc['enr.fc.ag'].value) < params.to",
                    "lang": "painless",
                    "position": {
                        "offset": 67,
                        "start": 0,
                        "end": 145
                    },
                    "caused_by": {
                        "type": "wrong_method_type_exception",
                        "reason": "wrong_method_type_exception: cannot convert MethodHandle(Longs)long to (Object)String"
                    }
                }
            }
        ],
        "caused_by": {
            "type": "wrong_method_type_exception",
            "reason": "wrong_method_type_exception: cannot convert MethodHandle(Longs)long to (Object)String"
        }
    },
    "status": 400
} 

Mapping of enr.fc.ag is

"type": "object",
"enabled": false,
"storeSource": true,
"sourceAvailable": true
}

Sample Doc

{
        "_index": "lst_p124_v_14_20220814_2359",
        "_id": "FACEBOOK_15_120493494629294_8273663752645520",
        "_score": 2,
        "_source": {
          "gTm": 1660582804947,
          "sT": -2,
          "sampleKey": "40",
          "uMId": "FACEBOOK_15_120493494629294_8273663752645520",
          "mTm": 1660583197034,
          "mTp": "15",
          "hBResp": false,
          "iS": false,
          "snMId": "120493494629294_8273663752645520",
          "snCTYM": "2022_08",
          "gT": {
            "countries": ["global"],
            "countryList": [
              {
                "label": "Global",
                "key": "global"
              }
            ]
          },
          "pMTp": 0,
          "sTp": "LISTENING",
          "pVt": false,
          "mSTp": "80",
          "mVadd": {
            "m_dv": [
              "@jerangkah",
              "akun",
              "baca",
              "diduga",
              "diungkap",
              "dugaan",
              "foto",
              "group",
              "internal",
              "investigasi",
              "kantor",
              "karyawan",
              "karyawati",
              "kasus",
              "kawan",
              "kerjanya",
              "korban",
              "melakukan",
              "memberi",
              "menegaskan",
              "menjadi",
              "model",
              "pelecehan",
              "pendisiplinan",
              "pihaknya",
              "produk",
              "ramainya",
              "rekan",
              "respons",
              "secara",
              "seksual",
              "selengkapnya",
              "suami",
              "tindakan",
              "tolelir",
              "twitter",
              "usai"
            ],
            "m_url": [
              "https://www.pikiran-rakyat.com/nasional/pr-015278455/ada-tindakan-pendisiplinan-kawan-lama-group-tak-tolelir-dugaan-pelecehan-karyawan-di-kantor"
            ],
            "m_x_url": [
              "https://www.pikiran-rakyat.com/nasional/pr-015278455/ada-tindakan-pendisiplinan-kawan-lama-group-tak-tolelir-dugaan-pelecehan-karyawan-di-kantor"
            ]
          },
          "psnCTm": 0,
          "snT": "FACEBOOK",
          "hUMId": "8b6b99f8533375edacf38833e471a49d",
          "pL": "https://www.facebook.com/120493494629294/posts/8273663752645520/",
          "aId": "999998",
          "cId": "120493494629294_8273663752645520",
          "add": {
            "d_p": "BENCHMARKING",
            "d_s": "bmk",
            "lng": "id",
            "mHash": "9394db8abee8305bce3eaff55d2b96af",
            "m_en": "SPR_COMBO[id]ADA TINDAKAN PENDISIPLINAN, KAWAN LAMA GROUP TAK TOLELIR DUGAAN PELECEHAN KARYAWAN DI KANTOR\n\nKawan Lama Group memberi respons terhadap ramainya dugaan pelecehan seksual oleh sesama karyawan usai menjadi model foto produk kantor.\nKaryawati tersebut diduga menjadi korban pelecehan seksual sesama rekan kerjanya di kantor. Dugaan pelecehan ini diungkap oleh suami korban melalui akun Twitter @jerangkah.\nKawan Lama Group menegaskan pihaknya melakukan investigasi secara internal terhadap kasus dugaan pelecehan tersebut.\n\nBaca Selengkapnya: https://www.pikiran-rakyat.com/nasional/pr-015278455/ada-tindakan-pendisiplinan-kawan-lama-group-tak-tolelir-dugaan-pelecehan-karyawan-di-kantor",
            "m_t": "FACEBOOK",
            "sPId": "120493494629294",
            "source": "FACEBOOK",
            "BM_DATA_TYPE": "BM_FB_POST",
            "aUId": "BECHMARKING_ACCOUNT_USER_ID",
            "DACHIS_ACCOUNT_ID": "6bc98490-5b79-11e9-bf00-0a96e87d3ded",
            "ECOSYSTEM_ACCOUNT_ID": "6bc98490-5b79-11e9-bf00-0a96e87d3ded"
          },
          "tU": {
            "sN": "Pikiran Rakyat",
            "uI": "120493494629294",
            "snTypeSnId": "FACEBOOK_120493494629294",
            "pU": "https://www.facebook.com/pikiranrakyatonline",
            "verUser": "true",
            "pK": "FACEBOOK-:-120493494629294",
            "pIU": "https://scontent-iad3-2.xx.fbcdn.net/v/t1.6435-1/118636341_4651556881522910_7277055450305286954_n.jpg?stp=cp0_dst-jpg_p50x50&_nc_cat=108&ccb=1-7&_nc_sid=dbb9e7&_nc_ohc=LsdrJGlav6wAX94zdxj&_nc_ht=scontent-iad3-2.xx&edm=AJdBtusEAAAA&oh=00_AT_-EltqXZ94I6dNxElxmvcz_JbS49gLnVOyz3tyCSCQSw&oe=631E0453",
            "n": "Pikiran Rakyat"
          },
          "cRMTp": 0,
          "lng": "id",
          "addI": {
            "dD": {
              "alexaPageViews": 19789000000,
              "alexaRank": 3,
              "alexaReach": 113100000000,
              "dA": 96,
              "mozExternalLinks": 5594516407,
              "mozRank": 10,
              "mozSpamScore": 1,
              "swGR": 3,
              "swR": 387885022,
              "swTV": 1241358779
            },
            "eE": {
              "i": ["emotion", "sentimentServable"],
              "ut": {
                "sentimentServable": 1660582806565
              }
            },
            "lstDelay": {
              "gHr": 9
            },
            "lstKG": {
              "ord": [
                91, 179, 253, 254, 2320, 2388, 2430, 2481, 2509, 2640, 2660,
                2687, 2712, 3527, 3528, 3601, 3822, 3833, 4550, 4994, 5049,
                5058, 5066, 5204, 5578
              ]
            },
            "lstMTopic": {
              "ord": [14943]
            },
            "lstPL": {
              "ord": [10782, 10951, 10952, 11054, 11058]
            },
            "lstQuery": {
              "ord": [
                2987, 16945, 16947, 17581, 17588, 19799, 21318, 34159, 39079,
                39085, 39761, 46031, 48197, 49697, 50118, 53594, 58656, 58800,
                59429, 59797, 63966, 66540
              ]
            },
            "lstTheme": {
              "ord": [
                37, 53, 143, 150, 544, 1912, 5157, 5165, 5192, 5659, 5660, 5661,
                6268, 6337, 6537, 6598, 6624, 6694, 6787, 7295, 7346, 7363,
                7999, 8923, 8926, 9325, 12989, 13055, 13121, 13186, 13231,
                13292, 13353, 14363, 14585, 14616, 14876, 14891, 14912, 15114,
                15116, 15190, 15226, 15531, 15793, 16370, 16376, 16480, 16544,
                16612, 17118, 17372, 17461, 17468, 17519, 17768, 19070, 19071,
                19073, 19074, 20827, 21594, 21705, 21730, 21738, 21905, 21968,
                22146, 22183, 22185, 22282, 22283, 22363, 22365, 22398, 22454,
                22484, 22945, 23000, 23002, 23003, 23170, 23378, 23685, 23850,
                23851, 23852, 23962, 24313, 24349, 24867, 25221, 25702, 26881,
                26894, 27464, 27465, 27466, 27517, 27519, 27531, 27632, 27778,
                27894, 28080, 28209, 28318, 28374, 28436, 28481, 28751, 28752,
                28800, 28819, 28928, 28934, 28939, 29301, 29326, 29524, 29566,
                29818, 29936, 29939, 29940, 30246, 30687, 30803, 31348, 31983,
                32221, 32402, 32406, 32979, 32987, 32996, 32997, 33035, 35687,
                35748, 36030, 36297, 36957, 37010, 37038, 37105, 38667, 39137,
                39689, 39696, 39952, 40449, 41652, 42418, 42684, 42979, 43285,
                43377, 43648, 43688, 44055, 44140, 44355
              ]
            },
            "lstTopic": {
              "ord": [16, 295, 298, 299, 300, 306, 405]
            },
            "profileWorkflow": {
              "partnerCustomProperties": {
                "5624ef86da6f845351000002": ["100001-500000"],
                "5624f016da6f845351000003": ["Influencer - High Follower Count"]
              },
              "partnerProfileLists": [4, 1187, 1188, 1275],
              "partnerProfileListDetails": [
                {
                  "profileListId": 1275,
                  "userId": 636123,
                  "profileListAssignedTime": 1658315395508
                }
              ],
              "clientWorkflows": [
                {
                  "clientId": 12042,
                  "clientProfileListQueryField": [
                    "12042_3",
                    "12042_4",
                    "12042_5",
                    "12042_6"
                  ],
                  "clientProfileLists": [3, 4, 5, 6],
                  "clientProfileListDetails": [
                    {
                      "profileListId": 6,
                      "userId": 636123,
                      "profileListAssignedTime": 1658384068749
                    }
                  ],
                  "tags": []
                }
              ],
              "version": 8
            },
            "seeing": {
              "sIS": "IMAGE_SEEING_SUCCESS",
              "sSH": [
                {
                  "iU": "https://prod.cdata.app.sprinklr.com/BMK/9993342/b33a39e7-de54-4f1b-af93-d8f02c2c416c-1017844745/FACEBOOK_15_120493494629294_82.png",
                  "eS": [
                    {
                      "st": "IMAGE_SEEING_SUCCESS",
                      "eT": "br"
                    }
                  ]
                }
              ]
            },
            "sem": {
              "_d_updatedTime_t": 1660582872677,
              "data": {
                "sentiment_polarity": "negative",
                "sentiment_score": 0.76605415
              },
              "submittedTime": 1660582843094,
              "semantriaSla": 17414,
              "esUpdateSla": 12169,
              "nlpEngineName": "spr-sentiment"
            },
            "tCl": {
              "eS": [
                {
                  "sc": 1,
                  "title": "Company",
                  "pol": "neutral",
                  "labels": ["Twitter"]
                }
              ]
            },
            "socialScoreCard": {
              "participationIndex": 0,
              "influencerIndex": 65,
              "spamIndex": 0
            },
            "mW": {
              "spcW": [],
              "uMId": "FACEBOOK_15_120493494629294_8273663752645520",
              "mTm": 1660582867509,
              "dtDetails": null,
              "mTp": 15,
              "cL": [],
              "snMId": "120493494629294_8273663752645520",
              "acl": {},
              "kbD": null,
              "aRSC": null,
              "sTp": "LISTENING",
              "glT": null,
              "clW": [],
              "mVadd": {
                "r_ids": [
                  "61dbf142b0dbe4664d332a29",
                  "5ed8e25f29e7b96865501788"
                ]
              },
              "pC": [],
              "cW": [],
              "resumeClockSeq": null,
              "glSt": null,
              "snT": "FACEBOOK",
              "uAD": null,
              "partnerWorkflowSuggestions": null,
              "id": "62fa7bbf732bda7d80ff07c5",
              "pCP": {
                "5ed8e11b29e7b968654fe36e": [
                  "Less Than 4 Weeks",
                  "Less Than 3 Weeks",
                  "Less Than 2 Weeks",
                  "Less Than 1 Week"
                ],
                "_c_61938912e74c3e225a4f004b": ["negative"]
              },
              "aId": null,
              "add": {},
              "pQ": [],
              "wkADs": null,
              "startClockSeq": null,
              "tmBPriorityDet": null,
              "snCTm": 1660549440000,
              "sInfos": [
                {
                  "sTp": "LISTENING",
                  "sTpSId": "LISTENING_-1",
                  "sId": -1
                }
              ],
              "classification": null,
              "numOfComments": null,
              "hasComment": null,
              "pRank": null,
              "sId": -1,
              "p": null,
              "vId": 2,
              "usrW": [],
              "iD": false,
              "slaBreachDetails": null,
              "pUD": []
            }
          },
          "iPBP": false,
          "iRM": false,
          "snCTm": 1660549440000,
          "enr": {
            "fc": {
              "_d_pRTm_t": [1660582837817],
              "aC": ["-1"],
              "ag": [-1]
            },
            "lc": {
              "cc2": ["UN"]
            },
            "wc": {
              "tokens": [
                "015278455",
                "akun",
                "baca",
                "diduga",
                "diungkap",
                "dugaan",
                "foto",
                "group",
                "internal",
                "investigasi",
                "jerangkah",
                "kantor",
                "karyawan",
                "karyawati",
                "kasus",
                "kawan",
                "kerjanya",
                "korban",
                "melakukan",
                "memberi",
                "menegaskan",
                "menjadi",
                "model",
                "nasional",
                "pelecehan",
                "pendisiplinan",
                "pihaknya",
                "pr",
                "produk",
                "rakyat.com",
                "ramainya",
                "rekan",
                "respons",
                "secara",
                "seksual",
                "selengkapnya",
                "suami",
                "tindakan",
                "tolelir",
                "twitter",
                "usai",
                "www.pikiran"
              ]
            }
          },
          "snSt": {
            "conLen": 684,
            "erEng": 2,
            "fC": 0,
            "iFsC": 65,
            "nEFR": 14437,
            "nF": 266731,
            "nL": 2,
            "nL_a_t": 1660721986994,
            "reC": 266731
          },
          "snMTm": 1660582804947,
          "fU": {
            "n": "Pikiran Rakyat",
            "pK": "FACEBOOK-:-120493494629294",
            "sN": "Pikiran Rakyat",
            "uI": "120493494629294",
            "verUser": "true",
            "pU": "https://www.facebook.com/pikiranrakyatonline",
            "pIU": "https://scontent-iad3-2.xx.fbcdn.net/v/t1.6435-1/118636341_4651556881522910_7277055450305286954_n.jpg?stp=cp0_dst-jpg_p50x50&_nc_cat=108&ccb=1-7&_nc_sid=dbb9e7&_nc_ohc=LsdrJGlav6wAX94zdxj&_nc_ht=scontent-iad3-2.xx&edm=AJdBtusEAAAA&oh=00_AT_-EltqXZ94I6dNxElxmvcz_JbS49gLnVOyz3tyCSCQSw&oe=631E0453"
          },
          "sId": "-1",
          "vId": 0,
          "iBP": false,
          "pSens": false,
          "mD": [
            {
              "nsfw": false,
              "name": "full",
              "type": "PHOTO",
              "picture": "https://prod.cdata.app.sprinklr.com/BMK/9993342/b33a39e7-de54-4f1b-af93-d8f02c2c416c-1017844745/FACEBOOK_15_120493494629294_82.png"
            }
          ],
          "hBP": false,
          "urlEntities": {
            "message": [
              {
                "resolvedUrl": "https://www.pikiran-rakyat.com/nasional/pr-015278455/ada-tindakan-pendisiplinan-kawan-lama-group-tak-tolelir-dugaan-pelecehan-karyawan-di-kantor",
                "expandedUrl": "https://www.pikiran-rakyat.com/nasional/pr-015278455/ada-tindakan-pendisiplinan-kawan-lama-group-tak-tolelir-dugaan-pelecehan-karyawan-di-kantor",
                "url": "https://www.pikiran-rakyat.com/nasional/pr-015278455/ada-tindakan-pendisiplinan-kawan-lama-group-tak-tolelir-dugaan-pelecehan-karyawan-di-kantor"
              }
            ]
          },
          "iA": false,
          "textEntities": {
            "message": [
              {
                "indices": [540, 684],
                "striked": false,
                "copiableEntity": false,
                "url": "https://www.pikiran-rakyat.com/nasional/pr-015278455/ada-tindakan-pendisiplinan-kawan-lama-group-tak-tolelir-dugaan-pelecehan-karyawan-di-kantor",
                "piiEntity": false
              }
            ]
          },
          "iD": false,
          "cTm": 1660582821507
        }
      }

Can anyone help me identify what exactly am I doing wrong ?

I'd simplify a lot the example and provide a full curl recreation everyone can run from the Dev Console.

You should just keep:

  • a very simple index creation with the mapping with one field
  • a simple document with the field content
  • the script part from the query

And then we could more easily iterate from here.

1 Like

Created an index test6

curl --location --request PUT 'localhost:9200/test6' \
--header 'Content-Type: application/json' \
--data '{
    "mappings": {
        "_source": {
            "mode": "synthetic"
        },
        "properties": {
            "enr": {
                "storeSource": true,
                "properties": {
                    "fc": {
                        "properties": {
                            "ag": {
                                "type": "long"
                            }
                        }
                    }
                }
            }
        }
    }
}'

Inserted a document

curl --location 'localhost:9200/test6/_doc/1' \
--header 'Content-Type: application/json' \
--data '{
    "enr": {
        "fc": {
            "ag": [-1]
        }
    }
}'

Now when I run the following script

curl --location --request GET 'localhost:9200/test6/_search' \
--header 'Content-Type: application/json' \
--data '{
    "timeout": "900000ms",
    "query": {
        "constant_score": {
            "filter": {
                "bool": {
                    "must": {
                        "bool": {
                            "must": [
                                {
                                    "bool": {
                                        "must_not": {
                                            "bool": {
                                                "should": [
                                                    {
                                                        "script": {
                                                            "script": {
                                                                "inline": "doc['\''enr.fc.ag'\''].value != null && Integer.parseInt(doc['\''enr.fc.ag'\''].value) >= params.from && Integer.parseInt(doc['\''enr.fc.ag'\''].value) < params.to",
                                                                "lang": "painless",
                                                                "params": {
                                                                    "from": 0,
                                                                    "to": 18
                                                                }
                                                            }
                                                        }
                                                    },
                                                    {
                                                        "script": {
                                                            "script": {
                                                                "inline": "doc['\''enr.fc.ag'\''].value != null && Integer.parseInt(doc['\''enr.fc.ag'\''].value) >= params.from && Integer.parseInt(doc['\''enr.fc.ag'\''].value) < params.to",
                                                                "lang": "painless",
                                                                "params": {
                                                                    "from": 18,
                                                                    "to": 25
                                                                }
                                                            }
                                                        }
                                                    },
                                                    {
                                                        "script": {
                                                            "script": {
                                                                "inline": "doc['\''enr.fc.ag'\''].value != null && Integer.parseInt(doc['\''enr.fc.ag'\''].value) >= params.from && Integer.parseInt(doc['\''enr.fc.ag'\''].value) < params.to",
                                                                "lang": "painless",
                                                                "params": {
                                                                    "from": 25,
                                                                    "to": 35
                                                                }
                                                            }
                                                        }
                                                    },
                                                    {
                                                        "script": {
                                                            "script": {
                                                                "inline": "doc['\''enr.fc.ag'\''].value != null && Integer.parseInt(doc['\''enr.fc.ag'\''].value) >= params.from && Integer.parseInt(doc['\''enr.fc.ag'\''].value) < params.to",
                                                                "lang": "painless",
                                                                "params": {
                                                                    "from": 35,
                                                                    "to": 45
                                                                }
                                                            }
                                                        }
                                                    },
                                                    {
                                                        "script": {
                                                            "script": {
                                                                "inline": "doc['\''enr.fc.ag'\''].value != null && Integer.parseInt(doc['\''enr.fc.ag'\''].value) >= params.from && Integer.parseInt(doc['\''enr.fc.ag'\''].value) < params.to",
                                                                "lang": "painless",
                                                                "params": {
                                                                    "from": 45,
                                                                    "to": 55
                                                                }
                                                            }
                                                        }
                                                    }
                                                ]
                                            }
                                        }
                                    }
                                }
                            ]
                        }
                    }
                }
            }
        }
    },
    "size": "0"
}'

I get following error

{
    "error": {
        "root_cause": [
            {
                "type": "script_exception",
                "reason": "runtime error",
                "script_stack": [
                    "org.elasticsearch.server@8.11.1/org.elasticsearch.search.lookup.LeafDocLookup.getFactoryForDoc(LeafDocLookup.java:148)",
                    "org.elasticsearch.server@8.11.1/org.elasticsearch.search.lookup.LeafDocLookup.get(LeafDocLookup.java:191)",
                    "org.elasticsearch.server@8.11.1/org.elasticsearch.search.lookup.LeafDocLookup.get(LeafDocLookup.java:32)",
                    "doc['enr.fc.ag'].value != null && Integer.parseInt(doc['enr.fc.ag'].value) >= params.from && Integer.parseInt(doc['enr.fc.ag'].value) < params.to",
                    "    ^---- HERE"
                ],
                "script": "doc['enr.fc.ag'].value != null && Integer.parseInt(doc['enr.fc.ag'].value) >= params.from && Integer.parseInt(doc['enr.fc.ag'].value) < params.to",
                "lang": "painless",
                "position": {
                    "offset": 4,
                    "start": 0,
                    "end": 145
                }
            }
        ],
        "type": "search_phase_execution_exception",
        "reason": "all shards failed",
        "phase": "query",
        "grouped": true,
        "failed_shards": [
            {
                "shard": 0,
                "index": "test4",
                "node": "uygBPY2xTf2v7fxsZannjg",
                "reason": {
                    "type": "script_exception",
                    "reason": "runtime error",
                    "script_stack": [
                        "org.elasticsearch.server@8.11.1/org.elasticsearch.search.lookup.LeafDocLookup.getFactoryForDoc(LeafDocLookup.java:148)",
                        "org.elasticsearch.server@8.11.1/org.elasticsearch.search.lookup.LeafDocLookup.get(LeafDocLookup.java:191)",
                        "org.elasticsearch.server@8.11.1/org.elasticsearch.search.lookup.LeafDocLookup.get(LeafDocLookup.java:32)",
                        "doc['enr.fc.ag'].value != null && Integer.parseInt(doc['enr.fc.ag'].value) >= params.from && Integer.parseInt(doc['enr.fc.ag'].value) < params.to",
                        "    ^---- HERE"
                    ],
                    "script": "doc['enr.fc.ag'].value != null && Integer.parseInt(doc['enr.fc.ag'].value) >= params.from && Integer.parseInt(doc['enr.fc.ag'].value) < params.to",
                    "lang": "painless",
                    "position": {
                        "offset": 4,
                        "start": 0,
                        "end": 145
                    },
                    "caused_by": {
                        "type": "illegal_argument_exception",
                        "reason": "No field found for [enr.fc.ag] in mapping"
                    }
                }
            }
        ]
    },
    "status": 400
}

Anyone able to reproduce this and identify the issue ?

your field "ag" type is "long"

Integer.parseInt(doc['\''enr.fc.ag'\''].value)

Integer.parseInt(value) is try to String to Integer.

I think

Integer.parseInt(String.valueOf(doc['enr.fc.ag'].value))

is right.
hope it works

It was "Object" earlier, copied the wrong curl
Below is the correct curl.

curl --location --request PUT 'localhost:9200/test6' \
--header 'Content-Type: application/json' \
--data '{
    "mappings": {
        "_source": {
            "mode": "synthetic"
        },
        "properties": {
            "enr": {
                "sourceAvailable": true,
                "properties": {
                    "fc": {
                        "sourceAvailable": true,
                        "properties": {
                            "ag": {
                                "type": "object",
                                "enabled": false,
                                "storeSource": true,
                                "sourceAvailable": true
                            }
                        }
                    }
                }
            }
        }
    }
}'

Could you modify a bit your script so we can copy/paste it in a Kibana dev console and just run it?

Some thoughts:

  • Try without synthetic source
  • the object type expect that you will provide subfields with actual data. And you should use the actual field which contains the data in scripts. Not the object.

Have a look at the Elastic Stack and Solutions Help · Forums and Slack | Elastic page. It contains also lot of useful information on how to ask for help.

  • I have to use synthetic source. Since that is one of the reason why we are migrating from ES7 to ES8.
  • Same query works fine with ES7, not sure why do we need to change the type here.

What should be the type of enr.fc.ag here?

Modifying Scripts for Kibana dev console.

Index Creation:

PUT /test2
{
    "mappings": {
        "_source": {
            "mode": "synthetic"
        },
        "properties": {
            "enr": {
                "sourceAvailable": true,
                "properties": {
                    "fc": {
                        "sourceAvailable": true,
                        "properties": {
                            "ag": {
                                "type": "object",
                                "enabled": false,
                                "storeSource": true,
                                "sourceAvailable": true
                            }
                        }
                    }
                }
            }
        }
    }
}

Add Doc

POST /test2/_doc/1
{
    "enr": {
        "fc": {
            "ag": [-1]
        }
    }
}

Query

GET /test2/_search
{
  "timeout": "900000ms",
  "query": {
    "constant_score": {
      "filter": {
        "bool": {
          "must": {
            "bool": {
              "must": [
                {
                  "bool": {
                    "must_not": {
                      "bool": {
                        "should": [
                          {
                            "script": {
                              "script": {
                                "inline": "doc['enr.fc.ag'].value != null && Integer.parseInt(String.valueOf(doc['enr.fc.ag'].value)) >= params.from && Integer.parseInt(String.valueOf(doc['enr.fc.ag'].value)) < params.to",
                                "lang": "painless",
                                "params": {
                                  "from": 0,
                                  "to": 18
                                }
                              }
                            }
                          },
                          {
                            "script": {
                              "script": {
                                "inline": "doc['enr.fc.ag'].value != null && Integer.parseInt(String.valueOf(doc['enr.fc.ag'].value)) >= params.from && Integer.parseInt(String.valueOf(doc['enr.fc.ag'].value)) < params.to",
                                "lang": "painless",
                                "params": {
                                  "from": 18,
                                  "to": 25
                                }
                              }
                            }
                          },
                          {
                            "script": {
                              "script": {
                                "inline": "doc['enr.fc.ag'].value != null && Integer.parseInt(String.valueOf(doc['enr.fc.ag'].value)) >= params.from && Integer.parseInt(String.valueOf(doc['enr.fc.ag'].value)) < params.to",
                                "lang": "painless",
                                "params": {
                                  "from": 25,
                                  "to": 35
                                }
                              }
                            }
                          },
                          {
                            "script": {
                              "script": {
                                "inline": "doc['enr.fc.ag'].value != null && Integer.parseInt(String.valueOf(doc['enr.fc.ag'].value)) >= params.from && Integer.parseInt(String.valueOf(doc['enr.fc.ag'].value)) < params.to",
                                "lang": "painless",
                                "params": {
                                  "from": 35,
                                  "to": 45
                                }
                              }
                            }
                          },
                          {
                            "script": {
                              "script": {
                                "inline": "doc['enr.fc.ag'].value != null && Integer.parseInt(String.valueOf(doc['enr.fc.ag'].value)) >= params.from && Integer.parseInt(String.valueOf(doc['enr.fc.ag'].value)) < params.to",
                                "lang": "painless",
                                "params": {
                                  "from": 45,
                                  "to": 55
                                }
                              }
                            }
                          }
                        ]
                      }
                    }
                  }
                }
              ]
            }
          }
        }
      }
    }
  },
  "size": "0"
}

Did you try to run your script?

I tried in 8.13.4 and got this for the first call:

PUT /test2
{
    "mappings": {
        "_source": {
            "mode": "synthetic"
        },
        "properties": {
            "enr": {
                "sourceAvailable": true,
                "properties": {
                    "fc": {
                        "sourceAvailable": true,
                        "properties": {
                            "ag": {
                                "type": "object",
                                "enabled": false,
                                "storeSource": true,
                                "sourceAvailable": true
                            }
                        }
                    }
                }
            }
        }
    }
}
{
  "error": {
    "root_cause": [
      {
        "type": "mapper_parsing_exception",
        "reason": "Mapping definition for [ag] has unsupported parameters:  [sourceAvailable : true] [storeSource : true]"
      }
    ],
    "type": "mapper_parsing_exception",
    "reason": "Failed to parse mapping: Mapping definition for [ag] has unsupported parameters:  [sourceAvailable : true] [storeSource : true]",
    "caused_by": {
      "type": "mapper_parsing_exception",
      "reason": "Mapping definition for [ag] has unsupported parameters:  [sourceAvailable : true] [storeSource : true]"
    }
  },
  "status": 400
}

I'd write the mapping like this:

{
  "test2": {
    "mappings": {
      "_source": {
        "mode": "synthetic"
      },
      "properties": {
        "enr": {
          "properties": {
            "fc": {
              "properties": {
                "ag": {
                  "type": "long"
                }
              }
            }
          }
        }
      }
    }
  }
}

Basically, this works:

DELETE /test2
PUT /test2
{
  "mappings": {
    "_source": {
      "mode": "synthetic"
    }
  }
}
POST /test2/_doc/1
{
  "enr": {
    "fc": {
      "ag": [
        -1
      ]
    }
  }
}
GET /test2/_search
{
  "query": {
    "script": {
      "script": {
        "source": "doc['enr.fc.ag'].value != null && Integer.parseInt(String.valueOf(doc['enr.fc.ag'].value)) >= params.from && Integer.parseInt(String.valueOf(doc['enr.fc.ag'].value)) < params.to",
        "lang": "painless",
        "params": {
          "from": 0,
          "to": 18
        }
      }
    }
  }
}

And BTW, as you can see I made it much more easy and small as possible to just focus on the main problem...

1 Like

I am able to create the index as you can see above.

But with the mapping you have provided above I am unable to insert a document. Might be due to the changes we have made on elasticsearch. Getting:

{
    "error": {
        "root_cause": [
            {
                "type": "document_parsing_exception",
                "reason": "[7:1] failed to parse: Cannot invoke \"org.elasticsearch.search.lookup.SourceFilter.filterBytes(org.elasticsearch.search.lookup.Source)\" because \"sourceFilter\" is null"
            }
        ],
        "type": "document_parsing_exception",
        "reason": "[7:1] failed to parse: Cannot invoke \"org.elasticsearch.search.lookup.SourceFilter.filterBytes(org.elasticsearch.search.lookup.Source)\" because \"sourceFilter\" is null",
        "caused_by": {
            "type": "null_pointer_exception",
            "reason": "Cannot invoke \"org.elasticsearch.search.lookup.SourceFilter.filterBytes(org.elasticsearch.search.lookup.Source)\" because \"sourceFilter\" is null"
        }
    },
    "status": 400
}

I will try to figure this out. Thank you.

What kind of changes?
And you are not using Kibana either to run your tests.

Yes, I am using postman.
We usually take the Elasticsearch repository and customise it according to our needs. Have to check what all changes have been made by the team so far.

So you are using a non supported Elasticsearch build if I read this correctly.
I'd suggest that you start a docker standard elasticsearch version, try again with it.

If it works with the standard distribution but not with your modified version, then, you know what to do next :wink:

If it does not work with the standard distribution, then we can help :smiley:

2 Likes