Advertisement
Guest User

ElasticSearch_nested

a guest
Jun 26th, 2017
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.85 KB | None | 0 0
  1. Mapping:
  2.  
  3. PUT pets
  4. {
  5. "mappings": {
  6. "myPets": {
  7. "_all": { "enabled": false },
  8. "dynamic": "strict",
  9. "properties": {
  10. "user": { "type": "text" },
  11. "pets": {
  12. "type": "nested",
  13. "properties": {
  14. "name": { "type": "text" },
  15. "type": { "type": "text" },
  16. "breed": { "type": "text" },
  17. "description": { "type": "text" }
  18. }
  19. }
  20. }
  21. }
  22. }
  23. }
  24.  
  25.  
  26.  
  27.  
  28. Example entry (GET pets/_search?q=*:*):
  29.  
  30. {
  31. "took": 157,
  32. "timed_out": false,
  33. "_shards": {
  34. "total": 5,
  35. "successful": 5,
  36. "failed": 0
  37. },
  38. "hits": {
  39. "total": 1,
  40. "max_score": 1,
  41. "hits": [
  42. {
  43. "_index": "pets",
  44. "_type": "myPets",
  45. "_id": "UE2hJtfwIF88L7XDQmOo",
  46. "_score": 1,
  47. "_source": {
  48. "pets": {
  49. "name": "Nils",
  50. "type": "dog",
  51. "breed": "sheepdog",
  52. "description": "hairy"
  53. },
  54. "user": "jacob"
  55. }
  56. }
  57. ]
  58. }
  59. }
  60.  
  61.  
  62.  
  63. logstash configuration:
  64.  
  65. input {
  66. jdbc {
  67. jdbc_connection_string => "jdbc:mysql://localhost:3306/pets"
  68. jdbc_user => "root"
  69. jdbc_password => "st40ngP@ssw0rd"
  70. jdbc_driver_library => "D:\mysql-connector-java-5.1.42-bin.jar"
  71. jdbc_driver_class => "com.mysql.jdbc.Driver"
  72. statement => "SELECT name, type, breed, description FROM pets"
  73. }
  74. }
  75.  
  76. filter {
  77. mutate {
  78. rename => {
  79. "name" => "[pets][name]"
  80. "type" => "[pets][type]"
  81. "breed" => "[pets][breed]"
  82. "description" => "[pets][description]"
  83. }
  84.  
  85. remove_field => [
  86. "@timestamp",
  87. "@version"
  88. ]
  89. }
  90. }
  91.  
  92. output {
  93. stdout { codec => json_lines }
  94. elasticsearch {
  95. "hosts" => "localhost:9200"
  96. "index" => "pets"
  97. "document_type" => "myPets"
  98. }
  99. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement