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

Better handling of inline scripts in ingest #23824

Closed
clintongormley opened this issue Mar 30, 2017 · 8 comments
Closed

Better handling of inline scripts in ingest #23824

clintongormley opened this issue Mar 30, 2017 · 8 comments
Labels
:Data Management/Ingest Node Execution or management of Ingest Pipelines including GeoIP >enhancement good first issue low hanging fruit help wanted adoptme

Comments

@clintongormley
Copy link

Anywhere that scripts are used, we allow writing an inline script in a short form, eg:

{ "script": {
    "lang": "painless",
    "inline": "ctx.foo='bar'
}}

can also be written as:

{ "script": "ctx.foo='bar'"}

If I try this in ingest:

POST _ingest/pipeline/_simulate
{
  "pipeline": {
    "processors": [
      {
        "script": "ctx.foo='bar'"
      }
    ]
  },
  "docs": [
    {
      "_index": "t",
      "_type": "t",
      "_id": "1",
      "_source": {}
    }
  ]
}

I get:

     {
        "type": "class_cast_exception",
        "reason": "java.lang.String cannot be cast to java.util.Map"
      }

While I understand that all processors expect an object and so the short form may not be supported (although it'd be nice to make an exception for scripts), we should at least have an exception which is easier to understand.

@clintongormley clintongormley added :Data Management/Ingest Node Execution or management of Ingest Pipelines including GeoIP help wanted adoptme >enhancement good first issue low hanging fruit labels Mar 30, 2017
@Dimitrees
Copy link

Hello, I am new to both your project and working with GitHub in general. Can I work on resolving this issue since its labeled as Low Hanging Fruit?

Thanks

@asettouf
Copy link

Hello,

@Dimitrees are you still working on it, or can I pick it up?

Thanks,

Adonis

@Dimitrees
Copy link

Its yours, sorry for not unassigning myself earlier.

@asettouf
Copy link

asettouf commented May 1, 2017

Here is a PR regarding this issue. As it is one of my first PR, I look forward to your feedback.

@liketic
Copy link
Contributor

liketic commented Sep 21, 2017

@talevy Can I work on this? Thanks. 😄

@talevy
Copy link
Contributor

talevy commented Sep 21, 2017

yeah @liketic!

If you look at my comment here: #24410 (review), that is what I had in mind for a possible solution.

@liketic
Copy link
Contributor

liketic commented Sep 22, 2017

@talevy Thanks for your help. Seems like this issue is much complexer than I thought. We read the processor configs as List<Map<String, Map<String, Object>>>, and in all methods, we assume the value of each key in a Map is a Map, however, script allows the value to be a String. That's the problem. So I think we can resolve this through:

  1. Read processor configs as List<Map<String, Object>>. But for method readProcessor, we need to detect if the value object is a Map or a String. If it's a String, need to normalize it to a Map.
  2. In ScriptProcessor, parse Script by Script.parse as you mentioned. and clear all script related properties.

I didn't find another place can call the readScript method, because the script parsing is done in ScriptProcessor and ScriptProcessor is created in factory. So seems like this resolution is another work around. I'm not a expert to es, so I'm not sure if this resolution is make sense to you.
Happy to know your thoughts. Thanks very much!

@liketic
Copy link
Contributor

liketic commented Sep 30, 2017

@talevy I opened a PR as I thought. Please add your comments or close it if it does not make sense. Thanks. 😄

talevy pushed a commit that referenced this issue Oct 11, 2017
* Add support for parsing inline script (#23824)

* Fix test
jasontedor added a commit that referenced this issue Oct 12, 2017
* master: (35 commits)
  Create weights lazily in filter and filters aggregation (#26983)
  Use a dedicated ThreadGroup in rest sniffer (#26897)
  Fire global checkpoint sync under system context
  Update by Query is modified to accept short `script` parameter. (#26841)
  Cat shards bytes (#26952)
  Add support for parsing inline script (#23824) (#26846)
  Change default value to true for transpositions parameter of fuzzy query (#26901)
  Adding unreleased 5.6.4 version number to Version.java
  Rename TCPTransportTests to TcpTransportTests (#26954)
  Fix NPE for /_cat/indices when no primary shard (#26953)
  [DOCS] Fixed indentation of the definition list.
  Fix formatting in channel close test
  Check for closed connection while opening
  Clarify systemd overrides
  [DOCS] Plugin Installation for Windows (#21671)
  Painless: add tests for cached boxing (#24163)
  Don't detect source's XContentType in DocumentParser.parseDocument() (#26880)
  Fix handling of paths containing parentheses
  Allow only a fixed-size receive predictor (#26165)
  Add Homebrew instructions to getting started
  ...
jasontedor added a commit to olcbean/elasticsearch that referenced this issue Oct 16, 2017
* master: (356 commits)
  Do not set SO_LINGER on server channels (elastic#26997)
  Fix inconsistencies in the rest api specs for *_script (elastic#26971)
  fix inconsistencies in the rest api specs for cat.snapshots (elastic#26996)
  Add docs on full_id parameter in cat nodes API
  [TEST] Add test that replicates versioned updates with random flushes
  Use internal searcher for all indexing related operations in the engine
  Reformat paragraph in template docs to 80 columns
  Clarify settings and template on create index
  Fix reference to TcpTransport in documentation
  Allow Uid#decodeId to decode from a byte array slice (elastic#26987)
  Fix a typo in the similarity docs (elastic#26970)
  Use separate searchers for "search visibility" vs "move indexing buffer to disk (elastic#26972)
  Create weights lazily in filter and filters aggregation (elastic#26983)
  Use a dedicated ThreadGroup in rest sniffer (elastic#26897)
  Fire global checkpoint sync under system context
  Update by Query is modified to accept short `script` parameter. (elastic#26841)
  Cat shards bytes (elastic#26952)
  Add support for parsing inline script (elastic#23824) (elastic#26846)
  Change default value to true for transpositions parameter of fuzzy query (elastic#26901)
  Adding unreleased 5.6.4 version number to Version.java
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:Data Management/Ingest Node Execution or management of Ingest Pipelines including GeoIP >enhancement good first issue low hanging fruit help wanted adoptme
Projects
None yet
Development

No branches or pull requests

5 participants