Skip to content

[ML] domainSplit painless extension not available in runtime fields #71946

@davidkyle

Description

@davidkyle

The ml plugin defines a custom painless extension function domainSplit which splits a URL into the highest registered domain and subdomains. The function can be called via script_fields in a search but if called in runtime_mappings the script errors with:
Unknown call [domainSplit] with [[org.elasticsearch.painless.node.EDot@156a1756]] arguments

To Reproduce

PUT /domain-split-test
{
  "mappings":{
    "properties": {
      "url": {
        "type": "keyword" 
      }
    }
  }
}

POST /domain-split-test/_doc
{
  "url":"www.elastic.co"
}

# OK with script fields 
GET /domain-split-test/_search
{
  "script_fields":{
    "sub":{
      "script":"return domainSplit(doc['url'].value).get(0)"
    },
    "hrd":{
      "script":"return domainSplit(doc['url'].value).get(1);"
    }
  }
}

# Error using RT mappings
GET /domain-split-test/_search
{
  "runtime_mappings":{
    "sub":{
      "type": "keyword",
      "script":"emit(domainSplit(doc['url'].value).get(0))"
    },
    "hrd":{
      "type": "keyword",
      "script":"emit(domainSplit(doc['url'].value).get(1))"
    }
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    :mlMachine learningTeam:MLMeta label for the ML team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions