Guest User

Untitled

a guest
Nov 16th, 2018
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.39 KB | None | 0 0
  1. "mappings": {
  2. "mytype": {
  3. "properties": {
  4. "Myfield1": {
  5. "type": "nested",
  6. "properties": {
  7. "field1": {
  8. "type": "string"
  9. },
  10. "field2": {
  11. "type": "long"
  12. }
  13. }
  14. },
  15. "Title": {
  16. "type": "string"
  17. }
  18. }
  19. }
  20. }
  21.  
  22. {
  23. "query": {
  24. "match": {
  25. "Title": "elasticsearch"
  26. }
  27. },
  28. "script": "ctx._source.Myfield1 = [{'nestfield1':'foo blabla...','nestfield2':100},{'nestfield1':'abc...','nestfield2':200}]"
  29. }
  30.  
  31. "query" : {
  32. "match_all" : {}
  33. },
  34. "script" : "ctx._source.Myfield1 = Myfield1;",
  35. "params": {
  36. "Myfield1": {
  37. "nestfield1": "foo blabla..."
  38. }
  39. }
  40.  
  41. "query" : {
  42. "match_all" : {}
  43. },
  44. "script" : "ctx._source.Myfield1 = Myfield1; ctx._source.Myfield1.nestfield1 = ctx._source.Myfield1Nestfield1; ctx._source.Myfield1.nestfield2 = ctx._source.Myfield1Nestfield2;",
  45. "params": {
  46. "Myfield1": {
  47. "nestfield1": "init_data"
  48. }
  49. }
  50.  
  51. POST indexname/type/_update_by_query
  52. {
  53. "query": {
  54. "match": {
  55. "Title": "elasticsearch"
  56. }
  57. },
  58. "script": {
  59. "source": "ctx._source.Myfield1= params.mifieldAsParam",
  60. "params": {
  61. "mifieldAsParam": [
  62. {
  63. "nestfield1": "foo blabla...",
  64. "nestfield2": 100
  65. },
  66. {
  67. "nestfield1": "abc...",
  68. "nestfield2": 200
  69. }
  70. ]
  71. },
  72. "lang": "painless"
  73. }
  74. }
Add Comment
Please, Sign In to add comment