Advertisement
Guest User

Untitled

a guest
Feb 21st, 2019
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.66 KB | None | 0 0
  1. # ** EXAM OBJECTIVES: INDEXING DATA + MAPPINGS AND TEXT ANALYSIS **
  2. # (remove, if present, any `hamlet*` index and index template)
  3. # Create the index `hamlet_raw`, with one primary shard and four replicas
  4. # Index in `hamlet_raw` a document with id "1", default type, and the field `line` with value "To be, or not to be: that is the question"
  5. # Update the document with id "1" by adding the field `line_number` with value "3.1.64"
  6. # Index in `hamlet_raw` a new document without specifying any id. The fields of this document are: (i) `text_entry` with value "Whether tis nobler in the mind to suffer"; (ii) `line_number` with value "3.1.66"
  7. # Update the precedent document by setting `line_number` to "3.1.65"
  8. # (in one request) Update all documents in `hamlet_raw` by adding a new field `speaker` with value "HAMLET"
  9. # Update the document with id "1" by renaming the field `line` into `text_entry`
  10. # Delete the `hamlet_raw` index
  11. # Create the index template `hamlet_template`, which satisfies the following criteria: (i) it matches the index patterns "hamlet_*" and "hamlet-*"; (ii) it allocates one primary shard and no replicas for each matching index
  12. # Create two indices named `hamlet2` and `hamlet_test`. Verify that `hamlet_template` applied only to `hamlet_test`
  13. # (in one request) Delete the `hamlet2` and `hamlet_test` indices
  14. # Update `hamlet_template` by defining a mapping that satisfies the following criteria: (i) it defines a "_doc" type, with three fields named `speaker`, `line_number` and `text_entry`; (ii) `speaker` and `line_number` map to non-analysed strings; (iii) `text_entry` is a text associated with the "english" analyzer
  15. # Create the index `hamlet_1`, and populate it by running the _bulk command with the request-body below
  16. {"index":{"_index":"hamlet_1","_id":0}}
  17. {"line_number":"1.1.1","speaker":"BERNARDO","text_entry":"Whos there?"}
  18. {"index":{"_index":"hamlet_1","_id":1}}
  19. {"line_number":"1.1.2","speaker":"FRANCISCO","text_entry":"Nay, answer me: stand, and unfold yourself."}
  20. {"index":{"_index":"hamlet_1","_id":2}}
  21. {"line_number":"1.1.3","speaker":"BERNARDO","text_entry":"Long live the king!"}
  22. {"index":{"_index":"hamlet_1","_id":3}}
  23. {"line_number":"1.2.1","speaker":"KING CLAUDIUS","text_entry":"Though yet of Hamlet our dear brothers death"}
  24. {"index":{"_index":"hamlet_1","_id":4}}
  25. {"line_number":"1.2.2","speaker":"KING CLAUDIUS","text_entry":"The memory be green, and that it us befitted"}
  26. {"index":{"_index":"hamlet_1","_id":5}}
  27. {"line_number":"1.3.1","speaker":"LAERTES","text_entry":"My necessaries are embarkd: farewell:"}
  28. {"index":{"_index":"hamlet_1","_id":6}}
  29. {"line_number":"1.3.4","speaker":"LAERTES","text_entry":"But let me hear from you."}
  30. {"index":{"_index":"hamlet_1","_id":7}}
  31. {"line_number":"1.3.5","speaker":"OPHELIA","text_entry":"Do you doubt that?"}
  32. {"index":{"_index":"hamlet_1","_id":8}}
  33. {"line_number":"1.4.1","speaker":"HAMLET","text_entry":"The air bites shrewdly; it is very cold."}
  34. {"index":{"_index":"hamlet_1","_id":9}}
  35. {"line_number":"1.4.2","speaker":"HORATIO","text_entry":"It is a nipping and an eager air."}
  36. {"index":{"_index":"hamlet_1","_id":10}}
  37. {"line_number":"1.4.3","speaker":"HAMLET","text_entry":"What hour now?"}
  38. {"index":{"_index":"hamlet_1","_id":11}}
  39. {"line_number":"1.5.2","speaker":"Ghost","text_entry":"Mark me."}
  40. {"index":{"_index":"hamlet_1","_id":12}}
  41. {"line_number":"1.5.3","speaker":"HAMLET","text_entry":"I will."}
  42. # Create the index `hamlet_2`, and populate it by running the _bulk command with the request-body below
  43. {"index":{"_index":"hamlet_2","_id":14}}
  44. {"line_number":"2.1.1","speaker":"LORD POLONIUS","text_entry":"Give him this money and these notes, Reynaldo."}
  45. {"index":{"_index":"hamlet_2","_id":15}}
  46. {"line_number":"2.1.2","speaker":"REYNALDO","text_entry":"I will, my lord."}
  47. {"index":{"_index":"hamlet_2","_id":16}}
  48. {"line_number":"2.1.3","speaker":"LORD POLONIUS","text_entry":"You shall do marvellous wisely, good Reynaldo,"}
  49. {"index":{"_index":"hamlet_2","_id":17}}
  50. {"line_number":"2.1.4","speaker":"LORD POLONIUS","text_entry":"Before you visit him, to make inquire"}
  51. {"index":{"_index":"hamlet_2","_id":18}}
  52. {"line_number":"2.2.1","speaker":"KING CLAUDIUS","text_entry":"Welcome, dear Rosencrantz and Guildenstern!"}
  53. {"index":{"_index":"hamlet_2","_id":19}}
  54. {"line_number":"2.2.2","speaker":"KING CLAUDIUS","text_entry":"Moreover that we much did long to see you,"}
  55. {"index":{"_index":"hamlet_2","_id":20}}
  56. {"line_number":"2.2.3","speaker":"KING CLAUDIUS","text_entry":"The need we have to use you did provoke"}
  57. # Create an alias named `hamlet` that maps both `hamlet_1` and `hamlet_2`
  58. # Verify that the documents grouped in `hamlet` are 20
  59. # Allow the `hamlet` alias to write on index `hamlet_1`
  60. # Index in `hamlet` a document with id "13", default type, and the following fields: (i) `text_entry` with value "My hour is almost come,"; (ii) `line_number` with value "1.5.4"; (iii) `speaker`, with value "Ghost"
  61. # Update the mapping of `hamlet_template`, satisfying the following criteria: (i) remove the definitions of the `line_number` and `speaker` fields, (ii) disable aggregations for `text_entry`
  62. # Update the mapping of `hamlet_template` by adding a dynamic mapping that satisfies the following criteria: (i) it assigns an integer type to any field starting by "number_"; (ii) it maps every string to a non-analysed text
  63. # Create the index `hamlet_3`, and populate it by running the _bulk command with the request-body below
  64. {"index":{"_index":"hamlet_3","_id":21}}
  65. {"line_number":"3.1.4","speaker":"KING CLAUDIUS","text_entry":"With turbulent and dangerous lunacy?"}
  66. {"index":{"_index":"hamlet_3","_id":22}}
  67. {"line_number":"3.1.5","speaker":"ROSENCRANTZ","text_entry":"He does confess he feels himself distracted;"}
  68. {"index":{"_index":"hamlet_3","_id":23}}
  69. {"line_number":"3.1.64","speaker":"HAMLET","text_entry":"To be, or not to be: that is the question:"}
  70. {"index":{"_index":"hamlet_3","_id":24}}
  71. {"line_number":"3.1.65","speaker":"HAMLET","text_entry":"Whether tis nobler in the mind to suffer"}
  72. {"index":{"_index":"hamlet_3","_id":25}}
  73. {"line_number":"3.1.66","speaker":"HAMLET","text_entry":"The slings and arrows of outrageous fortune,"}
  74. {"index":{"_index":"hamlet_3","_id":26}}
  75. {"line_number":"3.1.67","speaker":"HAMLET","text_entry":"Or to take arms against a sea of troubles,"}
  76. {"index":{"_index":"hamlet_3","_id":27}}
  77. {"line_number":"3.1.68","speaker":"HAMLET","text_entry":"And by opposing end them? To die: to sleep;"}
  78. {"index":{"_index":"hamlet_3","_id":28}}
  79. {"line_number":"3.1.69","speaker":"HAMLET","text_entry":"No more; and by a sleep to say we end"}
  80. # Store in the cluster state a new script named `control_reindex_batch`, which checks whether the `reindexBatch` field exists in a document. In the affirmative case, then the script increments the field value by a parameter named `increment`; otherwise, the script sets the field value to 1
  81. # Reindex `hamlet` into `hamlet_3`, satisfying the following criteria: (i) disable refreshes of `hamlet_3` during the operation; (ii) apply the `control_reindex_batch` script with the `increment` parameter set to 1; (iii) reindex in two parallel slices
  82. # (in one request) Add `hamlet_3` to the alias `hamlet`, and delete the `hamlet_1` and `hamlet_2` indices
  83. # Update all the documents in `hamlet_3` by running the `control_reindex_batch` script with an `increment` of 10
  84. # Remove from `hamlet_3` the documents that have "KING CLAUDIUS" as `speaker`
  85. # Store in the cluster state a new ingest pipeline named `split_act_scene_line`, which satisfies the following criteria: (i) it splits the value of `line_number` by using dots as the separator; (ii) it stores the split values into three new numeric fields, named `number_act`, `number_scene`, and `number_line`, respectively
  86. # Update all documents in `hamlet_3` using the `split_act_scene_line` pipeline
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement