# Inline script search capability

**URL:** <https://discuss.elastic.co/t/inline-script-search-capability/360451>\
**Category:** Elasticsearch\
**Tags:** painless\
**Created:** [May 29, 2024, 11:05am UTC](https://discuss.elastic.co/t/inline-script-search-capability/360451 "2024-05-29T11:05:49Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Hossein\_Bagherzadega](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/hossein_bagherzadega/32/134893_2.png) [@Hossein\_Bagherzadega](https://discuss.elastic.co/u/Hossein_Bagherzadega)\
**Post date:** [May 29, 2024, 11:05am UTC](https://discuss.elastic.co/t/inline-script-search-capability/360451/1 "2024-05-29T11:05:49Z")

</div>

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

```auto
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

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [June 26, 2024, 11:06am UTC](https://discuss.elastic.co/t/inline-script-search-capability/360451/2 "2024-06-26T11:06:15Z")

</div>

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