Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mapping transform doesn't support file and indexed scripts #10113

Closed
javanna opened this issue Mar 16, 2015 · 6 comments · Fixed by #11164
Closed

Mapping transform doesn't support file and indexed scripts #10113

javanna opened this issue Mar 16, 2015 · 6 comments · Fixed by #11164
Assignees
Labels
>bug :Core/Infra/Scripting Scripting abstractions, Painless, and Mustache help wanted adoptme v2.0.0-beta1

Comments

@javanna
Copy link
Member

javanna commented Mar 16, 2015

Looks like the mapping transform feature supports dynamic scripts only. When submitting the following request:

curl -XPUT localhost:9200/test -d '{
  "mappings" : {
    "example" : {
        "transform" : {
            "script_id" : "1",
            "lang": "groovy"
        }
    }
  }
}
'

the mapping stored in the cluster state becomes the following, hence it loses the information about where the script should be loaded from:

{
  "test": {
    "mappings": {
      "example": {
        "transform": {
          "script": "1",
          "lang": "groovy"
        },
        "properties": {
          "test": {
            "type": "string"
          }
        }
      }
    }
  }
}

Might relate to #9995.

@clintongormley clintongormley added the :Core/Infra/Scripting Scripting abstractions, Painless, and Mustache label Apr 4, 2015
@clintongormley
Copy link

@colings86 i thought that the change in #11164 would fix this, but apparently not?

@colings86
Copy link
Contributor

@clintongormley it should do. Have you tried it?

@clintongormley
Copy link

yes, eg i save a file called test.groovy, then

PUT t
{
  "mappings": {
    "t": {
      "transform": {
        "script": {
          "file": "test"
        }
      }
    }
  }
}

then i get:

{
   "error": {
      "root_cause": [
         {
            "type": "script_parse_exception",
            "reason": "Value must be of type String: [script]"
         }
      ],
      "type": "mapper_parsing_exception",
      "reason": "mapping [t]",
      "caused_by": {
         "type": "script_parse_exception",
         "reason": "Value must be of type String: [script]"
      }
   },
   "status": 400
}

@colings86
Copy link
Contributor

Hmm, ok I'll take a look

@colings86
Copy link
Contributor

@clintongormley currently the transform object is treated as the script (this is actually (almost) backwards compatible as previously the transform object could have lang, script and params fields) , which is why you are getting the error. The following request does work:

PUT t
{
  "mappings": {
    "t": {
      "transform": {
          "file": "test"
      }
    }
  }
}

I can change it so that we require the script object under the transform object but since we only have scripted transforms it seemed cleaner this way. WDYT?

@clintongormley
Copy link

@colings86 doh - i should have realised. thanks for testing.

Closed by #11164

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>bug :Core/Infra/Scripting Scripting abstractions, Painless, and Mustache help wanted adoptme v2.0.0-beta1
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants