Advertisement
Guest User

Untitled

a guest
Dec 8th, 2016
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.47 KB | None | 0 0
  1. Table1
  2. Col_id| name| prop1|prop2|prop3
  3.  
  4. child_table1
  5. col_id| table_id| child_prop1|child_prop2|child_prop3
  6.  
  7.  
  8. curl -XPUT 'localhost:9200/_river/parent/_meta' -d '{
  9. "type" : "jdbc",
  10. "jdbc" : {
  11. "driver" : "com.mysql.jdbc.Driver",
  12. "url" : "jdbc:mysql://localhost:3306/test",
  13. "user" : "",
  14. "password" : "",
  15. "sql" : "select * from table1",
  16. "index" : "index1",
  17. "type" : "parent"
  18. }
  19. }'
  20.  
  21. curl -XPUT 'localhost:9200/_river/child/_meta' -d '{
  22. "type" : "jdbc",
  23. "jdbc" : {
  24. "driver" : "com.mysql.jdbc.Driver",
  25. "url" : "jdbc:mysql://localhost:3306/test",
  26. "user" : "",
  27. "password" : "",
  28. "sql" : "select * from child_table1",
  29. "index" : "index1",
  30. "type" : "child"
  31. }
  32. }'
  33.  
  34.  
  35.  
  36. curl -XPOST 'localhost:9200/_river/child/_mapping' -d '{
  37. "child":{
  38. "_parent": {"type": "parent"}
  39. }
  40. }'
  41.  
  42. {
  43. "id": "1",
  44. "name": "A leading wordsmith",
  45. "prop1": "data",
  46. "prop2": "data",
  47. "prop3": "data",
  48.  
  49. "child": [
  50. {
  51. "child_prop1": "data",
  52. "child_prop2": "data",
  53. "child_prop3": "data",
  54. }
  55. {
  56. "child_prop1": "data1",
  57. "child_prop2": "data1",
  58. "child_prop3": "data1",
  59. }
  60. ]
  61. }
  62.  
  63. curl -XPOST 'http://localhost:9200/library' -d '{
  64. "settings": {
  65. "number_of_shards": 1,
  66. "number_of_replicas": 0
  67. },
  68. "mappings": {
  69. "person": {
  70. "properties": {
  71. "person_id": {
  72. "type": "integer"
  73. },
  74. "name": {
  75. "type": "string"
  76. }
  77. }
  78. },
  79. "work": {
  80. "_parent": {
  81. "type": "person"
  82. },
  83. "properties": {
  84. "person_id": {
  85. "type": "integer",
  86. "index": "not_analyzed"
  87. },
  88. "name": {
  89. "type": "string"
  90. },
  91. "genre": {
  92. "type": "string"
  93. },
  94. "publisher": {
  95. "type": "string"
  96. }
  97. }
  98. }
  99. }
  100. }'
  101.  
  102. curl -XPUT localhost:9200/_river/person/_meta -d '{
  103. "type": "jdbc",
  104. "jdbc": {
  105. "driver": "com.microsoft.sqlserver.jdbc.SQLServerDriver",
  106. "url": "jdbc:sqlserver://127.0.0.1:1433;databaseName=blogcontext",
  107. "user": "sa",
  108. "password": "password",
  109. "sql": "select person_id as _id, name from person",
  110. "poll": "30s"
  111. },
  112. "index": {
  113. "index": "library",
  114. "type": "person",
  115. "bulk_size": 500,
  116. "autocommit": true
  117. }
  118. }'
  119.  
  120. curl -XPUT localhost:9200/_river/work/_meta -d '{
  121. "type": "jdbc",
  122. "jdbc": {
  123. "driver": "com.microsoft.sqlserver.jdbc.SQLServerDriver",
  124. "url": "jdbc:sqlserver://127.0.0.1:1433;databaseName=blogcontext",
  125. "user": "sa",
  126. "password": "password",
  127. "sql": "select person_id as _parent,name,genre,publisher from work",
  128. "poll": "30s"
  129. },
  130. "index": {
  131. "index": "library",
  132. "type": "work",
  133. "bulk_size": 500,
  134. "autocommit": true
  135. }
  136. }'
  137.  
  138. [2014-01-14 07:10:35,488][ERROR][OneShotRiverMouth ] bulk [1] error
  139. org.elasticsearch.ElasticSearchIllegalArgumentException: Can't specify parent if no parent field has been configured
  140. at org.elasticsearch.action.index.IndexRequest.process(IndexRequest.java:597)
  141. at org.elasticsearch.action.bulk.TransportBulkAction.executeBulk(TransportBulkAction.java:165)
  142. at org.elasticsearch.action.bulk.TransportBulkAction.doExecute(TransportBulkAction.java:140)
  143. at org.elasticsearch.action.bulk.TransportBulkAction.doExecute(TransportBulkAction.java:63)
  144. at org.elasticsearch.action.support.TransportAction.execute(TransportAction.java:63)
  145. at org.elasticsearch.client.node.NodeClient.execute(NodeClient.java:92)
  146. at org.elasticsearch.client.support.AbstractClient.bulk(AbstractClient.java:149)
  147. at org.elasticsearch.action.bulk.BulkProcessor.execute(BulkProcessor.java:283)
  148. at org.elasticsearch.action.bulk.BulkProcessor.access$400(BulkProcessor.java:46)
  149. at org.elasticsearch.action.bulk.BulkProcessor$Flush.run(BulkProcessor.java:336)
  150. at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
  151. at java.util.concurrent.FutureTask$Sync.innerRunAndReset(FutureTask.java:351)
  152. at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:178)
  153. at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:178)
  154. at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)
  155. at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
  156. at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
  157. at java.lang.Thread.run(Thread.java:724)
  158.  
  159. table1
  160. table_id| name| prop1|prop2|prop3
  161.  
  162. child_table1
  163. child_id| table_id| child_prop1|child_prop2|child_prop3
  164.  
  165. curl -XPUT 'localhost:9200/_river/parent/_meta' -d '{
  166. "type" : "jdbc",
  167. "jdbc" : {
  168. "driver" : "com.mysql.jdbc.Driver",
  169. "url" : "jdbc:mysql://localhost:3306/test",
  170. "user" : "",
  171. "password" : "",
  172. "sql" : "select table_id as _id, name, prop1, prop2, prop3 from table1",
  173. "index" : "index1",
  174. "type" : "parent"
  175. }
  176. }'
  177.  
  178. curl -XPUT 'localhost:9200/_river/child/_meta' -d '{
  179. "type" : "jdbc",
  180. "jdbc" : {
  181. "driver" : "com.mysql.jdbc.Driver",
  182. "url" : "jdbc:mysql://localhost:3306/test",
  183. "user" : "",
  184. "password" : "",
  185. "sql" : "select child_id as _id, table_id as _parent, child_prop1, child_prop2, child_prop3 from child_table1",
  186. "index" : "index1",
  187. "type" : "child"
  188. }
  189. }'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement