Inline script search capability

i need to search and index inside an inline script but could not find any docs or sample for it is the any chance that inline script support search on index something like this

query": {
    "bool": {
      "must_not": {
        "script": {
          "script": {
            "source": """
              def restrictionType = params.restriction.type;
              def customerBusinessUnitUuid = params.restriction.customerBusinessUnitUuid;
              def searchResult = ctx._index("product_restriction_index").search(,'{"bool": {"must": [{ "match": { "type": restrictionType } },{ "match": { "customer_business_unit_uuid": customerBusinessUnitUuid } }]}}');
              def restrictionUuids = searchResult.hits.hits.collect(hit -> hit._source['productUuid.keyword'].value);
              def currentDirectSku = doc['directSku.keyword'].value;
              def isInRestrictionUuids = restrictionUuids.contains(currentDirectSku);
              (restrictionType == 'whitelist' && !isInRestrictionUuids) || (restrictionType == 'blacklist' && isInRestrictionUuids);
            """,
            "lang": "painless",
            "params": {
              "restriction": { 
                "type": "whitelist", 
                "customerBusinessUnitUuid": "4a415944-76f5-41c8-b229-48b52be619f5" 
              }
            }
          }
        }
      }
    }

this syntax its not correct it kinda sudo code i wanna know if its possible or not

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.