Mapping: How to do your own calculations

How can we do our own calculations through mappings? I've try this configuration but I get an error:

PUT nameIndex/_mapping
  "runtime": {
    "cpuIndex": {
      "type": "long",
      "script": {
        "source": "emit(doc['system.cpu.cores'].value + doc['system.cpu.system.pct'].value) / doc['system.cpu.cores'].value)"

Can you share what error you're getting?

Hi @NoobUser404

Well for 1 you have a syntax error and extra ) here doc['system.cpu.system.pct'].value) <!---

Also I am not sure if that is just a sample calc but it really does not make sense adding the normalized CPU % to the number of cores.

3rd that will probably result in a double and you have a long defined

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