build.gradle 44 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283
  1. import static org.elasticsearch.gradle.testclusters.TestDistribution.DEFAULT
  2. /*
  3. * Licensed to Elasticsearch under one or more contributor
  4. * license agreements. See the NOTICE file distributed with
  5. * this work for additional information regarding copyright
  6. * ownership. Elasticsearch licenses this file to you under
  7. * the Apache License, Version 2.0 (the "License"); you may
  8. * not use this file except in compliance with the License.
  9. * You may obtain a copy of the License at
  10. *
  11. * http://www.apache.org/licenses/LICENSE-2.0
  12. *
  13. * Unless required by applicable law or agreed to in writing,
  14. * software distributed under the License is distributed on an
  15. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  16. * KIND, either express or implied. See the License for the
  17. * specific language governing permissions and limitations
  18. * under the License.
  19. */
  20. apply plugin: 'elasticsearch.docs-test'
  21. /* List of files that have snippets that will not work until platinum tests can occur ... */
  22. buildRestTests.expectedUnconvertedCandidates = [
  23. 'reference/ml/anomaly-detection/transforms.asciidoc',
  24. 'reference/ml/anomaly-detection/apis/delete-calendar-event.asciidoc',
  25. 'reference/ml/anomaly-detection/apis/get-bucket.asciidoc',
  26. 'reference/ml/anomaly-detection/apis/get-category.asciidoc',
  27. 'reference/ml/anomaly-detection/apis/get-influencer.asciidoc',
  28. 'reference/ml/anomaly-detection/apis/get-job-stats.asciidoc',
  29. 'reference/ml/anomaly-detection/apis/get-overall-buckets.asciidoc',
  30. 'reference/ml/anomaly-detection/apis/get-record.asciidoc',
  31. 'reference/ml/anomaly-detection/apis/get-snapshot.asciidoc',
  32. 'reference/ml/anomaly-detection/apis/post-data.asciidoc',
  33. 'reference/ml/anomaly-detection/apis/revert-snapshot.asciidoc',
  34. 'reference/ml/anomaly-detection/apis/update-snapshot.asciidoc',
  35. ]
  36. testClusters.integTest {
  37. if (singleNode().testDistribution == DEFAULT) {
  38. setting 'xpack.license.self_generated.type', 'trial'
  39. }
  40. // enable regexes in painless so our tests don't complain about example snippets that use them
  41. setting 'script.painless.regex.enabled', 'true'
  42. setting 'path.repo', "${buildDir}/cluster/shared/repo"
  43. Closure configFile = {
  44. extraConfigFile it, file("src/test/cluster/config/$it")
  45. }
  46. configFile 'analysis/example_word_list.txt'
  47. configFile 'analysis/hyphenation_patterns.xml'
  48. configFile 'analysis/synonym.txt'
  49. configFile 'analysis/stemmer_override.txt'
  50. configFile 'userdict_ja.txt'
  51. configFile 'userdict_ko.txt'
  52. configFile 'KeywordTokenizer.rbbi'
  53. extraConfigFile 'hunspell/en_US/en_US.aff', project(":server").file('src/test/resources/indices/analyze/conf_dir/hunspell/en_US/en_US.aff')
  54. extraConfigFile 'hunspell/en_US/en_US.dic', project(":server").file('src/test/resources/indices/analyze/conf_dir/hunspell/en_US/en_US.dic')
  55. // Whitelist reindexing from the local node so we can test it.
  56. setting 'reindex.remote.whitelist', '127.0.0.1:*'
  57. // TODO: remove this once cname is prepended to transport.publish_address by default in 8.0
  58. systemProperty 'es.transport.cname_in_publish_address', 'true'
  59. }
  60. // build the cluster with all plugins
  61. project.rootProject.subprojects.findAll { it.parent.path == ':plugins' }.each { subproj ->
  62. /* Skip repositories. We just aren't going to be able to test them so it
  63. * doesn't make sense to waste time installing them. */
  64. if (subproj.path.startsWith(':plugins:repository-')) {
  65. return
  66. }
  67. // FIXME
  68. subproj.afterEvaluate { // need to wait until the project has been configured
  69. testClusters.integTest {
  70. plugin file(subproj.bundlePlugin.archiveFile)
  71. }
  72. tasks.integTest.dependsOn subproj.bundlePlugin
  73. }
  74. }
  75. buildRestTests.docs = fileTree(projectDir) {
  76. // No snippets in here!
  77. exclude 'build.gradle'
  78. // That is where the snippets go, not where they come from!
  79. exclude 'build'
  80. // Just syntax examples
  81. exclude 'README.asciidoc'
  82. // Broken code snippet tests
  83. exclude 'reference/graph/explore.asciidoc'
  84. }
  85. listSnippets.docs = buildRestTests.docs
  86. Closure setupTwitter = { String name, int count ->
  87. buildRestTests.setups[name] = '''
  88. - do:
  89. indices.create:
  90. index: twitter
  91. body:
  92. settings:
  93. number_of_shards: 1
  94. number_of_replicas: 1
  95. mappings:
  96. properties:
  97. user:
  98. type: keyword
  99. doc_values: true
  100. date:
  101. type: date
  102. likes:
  103. type: long
  104. - do:
  105. bulk:
  106. index: twitter
  107. refresh: true
  108. body: |'''
  109. for (int i = 0; i < count; i++) {
  110. String user, text
  111. if (i == 0) {
  112. user = 'kimchy'
  113. text = 'trying out Elasticsearch'
  114. } else {
  115. user = 'test'
  116. text = "some message with the number $i"
  117. }
  118. buildRestTests.setups[name] += """
  119. {"index":{"_id": "$i"}}
  120. {"user": "$user", "message": "$text", "date": "2009-11-15T14:12:12", "likes": $i}"""
  121. }
  122. }
  123. setupTwitter('twitter', 5)
  124. setupTwitter('big_twitter', 120)
  125. setupTwitter('huge_twitter', 1200)
  126. buildRestTests.setups['host'] = '''
  127. # Fetch the http host. We use the host of the master because we know there will always be a master.
  128. - do:
  129. cluster.state: {}
  130. - set: { master_node: master }
  131. - do:
  132. nodes.info:
  133. metric: [ http, transport ]
  134. - set: {nodes.$master.http.publish_address: host}
  135. - set: {nodes.$master.transport.publish_address: transport_host}
  136. '''
  137. buildRestTests.setups['node'] = '''
  138. # Fetch the node name. We use the host of the master because we know there will always be a master.
  139. - do:
  140. cluster.state: {}
  141. - is_true: master_node
  142. - set: { master_node: node_name }
  143. '''
  144. // Used by scripted metric docs
  145. buildRestTests.setups['ledger'] = '''
  146. - do:
  147. indices.create:
  148. index: ledger
  149. body:
  150. settings:
  151. number_of_shards: 2
  152. number_of_replicas: 1
  153. mappings:
  154. properties:
  155. type:
  156. type: keyword
  157. amount:
  158. type: double
  159. - do:
  160. bulk:
  161. index: ledger
  162. refresh: true
  163. body: |
  164. {"index":{}}
  165. {"date": "2015/01/01 00:00:00", "amount": 200, "type": "sale", "description": "something"}
  166. {"index":{}}
  167. {"date": "2015/01/01 00:00:00", "amount": 10, "type": "expense", "decription": "another thing"}
  168. {"index":{}}
  169. {"date": "2015/01/01 00:00:00", "amount": 150, "type": "sale", "description": "blah"}
  170. {"index":{}}
  171. {"date": "2015/01/01 00:00:00", "amount": 50, "type": "expense", "description": "cost of blah"}
  172. {"index":{}}
  173. {"date": "2015/01/01 00:00:00", "amount": 50, "type": "expense", "description": "advertisement"}'''
  174. // Used by aggregation docs
  175. buildRestTests.setups['sales'] = '''
  176. - do:
  177. indices.create:
  178. index: sales
  179. body:
  180. settings:
  181. number_of_shards: 2
  182. number_of_replicas: 1
  183. mappings:
  184. properties:
  185. type:
  186. type: keyword
  187. - do:
  188. bulk:
  189. index: sales
  190. refresh: true
  191. body: |
  192. {"index":{}}
  193. {"date": "2015/01/01 00:00:00", "price": 200, "promoted": true, "rating": 1, "type": "hat"}
  194. {"index":{}}
  195. {"date": "2015/01/01 00:00:00", "price": 200, "promoted": true, "rating": 1, "type": "t-shirt"}
  196. {"index":{}}
  197. {"date": "2015/01/01 00:00:00", "price": 150, "promoted": true, "rating": 5, "type": "bag"}
  198. {"index":{}}
  199. {"date": "2015/02/01 00:00:00", "price": 50, "promoted": false, "rating": 1, "type": "hat"}
  200. {"index":{}}
  201. {"date": "2015/02/01 00:00:00", "price": 10, "promoted": true, "rating": 4, "type": "t-shirt"}
  202. {"index":{}}
  203. {"date": "2015/03/01 00:00:00", "price": 200, "promoted": true, "rating": 1, "type": "hat"}
  204. {"index":{}}
  205. {"date": "2015/03/01 00:00:00", "price": 175, "promoted": false, "rating": 2, "type": "t-shirt"}'''
  206. // Used by cumulative cardinality aggregation docs
  207. buildRestTests.setups['user_hits'] = '''
  208. - do:
  209. indices.create:
  210. index: user_hits
  211. body:
  212. settings:
  213. number_of_shards: 1
  214. number_of_replicas: 0
  215. mappings:
  216. properties:
  217. user_id:
  218. type: keyword
  219. timestamp:
  220. type: date
  221. - do:
  222. bulk:
  223. index: user_hits
  224. refresh: true
  225. body: |
  226. {"index":{}}
  227. {"timestamp": "2019-01-01T13:00:00", "user_id": "1"}
  228. {"index":{}}
  229. {"timestamp": "2019-01-01T13:00:00", "user_id": "2"}
  230. {"index":{}}
  231. {"timestamp": "2019-01-02T13:00:00", "user_id": "1"}
  232. {"index":{}}
  233. {"timestamp": "2019-01-02T13:00:00", "user_id": "3"}
  234. {"index":{}}
  235. {"timestamp": "2019-01-03T13:00:00", "user_id": "1"}
  236. {"index":{}}
  237. {"timestamp": "2019-01-03T13:00:00", "user_id": "2"}
  238. {"index":{}}
  239. {"timestamp": "2019-01-03T13:00:00", "user_id": "4"}'''
  240. // Dummy bank account data used by getting-started.asciidoc
  241. buildRestTests.setups['bank'] = '''
  242. - do:
  243. indices.create:
  244. index: bank
  245. body:
  246. settings:
  247. number_of_shards: 5
  248. number_of_routing_shards: 5
  249. - do:
  250. bulk:
  251. index: bank
  252. refresh: true
  253. body: |
  254. #bank_data#
  255. '''
  256. /* Load the actual accounts only if we're going to use them. This complicates
  257. * dependency checking but that is a small price to pay for not building a
  258. * 400kb string every time we start the build. */
  259. File accountsFile = new File("$projectDir/src/test/resources/accounts.json")
  260. buildRestTests.inputs.file(accountsFile)
  261. buildRestTests.doFirst {
  262. String accounts = accountsFile.getText('UTF-8')
  263. // Indent like a yaml test needs
  264. accounts = accounts.replaceAll('(?m)^', ' ')
  265. buildRestTests.setups['bank'] =
  266. buildRestTests.setups['bank'].replace('#bank_data#', accounts)
  267. }
  268. // Used by index boost doc
  269. buildRestTests.setups['index_boost'] = '''
  270. - do:
  271. indices.create:
  272. index: index1
  273. - do:
  274. indices.create:
  275. index: index2
  276. - do:
  277. indices.put_alias:
  278. index: index1
  279. name: alias1
  280. '''
  281. // Used by sampler and diversified-sampler aggregation docs
  282. buildRestTests.setups['stackoverflow'] = '''
  283. - do:
  284. indices.create:
  285. index: stackoverflow
  286. body:
  287. settings:
  288. number_of_shards: 1
  289. number_of_replicas: 1
  290. mappings:
  291. properties:
  292. author:
  293. type: keyword
  294. tags:
  295. type: keyword
  296. - do:
  297. bulk:
  298. index: stackoverflow
  299. refresh: true
  300. body: |'''
  301. // Make Kibana strongly connected to elasticsearch and logstash
  302. // Make Kibana rarer (and therefore higher-ranking) than JavaScript
  303. // Make JavaScript strongly connected to jquery and angular
  304. // Make Cabana strongly connected to elasticsearch but only as a result of a single author
  305. for (int i = 0; i < 150; i++) {
  306. buildRestTests.setups['stackoverflow'] += """
  307. {"index":{}}
  308. {"author": "very_relevant_$i", "tags": ["elasticsearch", "kibana"]}"""
  309. }
  310. for (int i = 0; i < 50; i++) {
  311. buildRestTests.setups['stackoverflow'] += """
  312. {"index":{}}
  313. {"author": "very_relevant_$i", "tags": ["logstash", "kibana"]}"""
  314. }
  315. for (int i = 0; i < 200; i++) {
  316. buildRestTests.setups['stackoverflow'] += """
  317. {"index":{}}
  318. {"author": "partially_relevant_$i", "tags": ["javascript", "jquery"]}"""
  319. }
  320. for (int i = 0; i < 200; i++) {
  321. buildRestTests.setups['stackoverflow'] += """
  322. {"index":{}}
  323. {"author": "partially_relevant_$i", "tags": ["javascript", "angular"]}"""
  324. }
  325. for (int i = 0; i < 50; i++) {
  326. buildRestTests.setups['stackoverflow'] += """
  327. {"index":{}}
  328. {"author": "noisy author", "tags": ["elasticsearch", "cabana"]}"""
  329. }
  330. buildRestTests.setups['stackoverflow'] += """
  331. """
  332. // Used by significant_text aggregation docs
  333. buildRestTests.setups['news'] = '''
  334. - do:
  335. indices.create:
  336. index: news
  337. body:
  338. settings:
  339. number_of_shards: 1
  340. number_of_replicas: 1
  341. mappings:
  342. properties:
  343. source:
  344. type: keyword
  345. content:
  346. type: text
  347. - do:
  348. bulk:
  349. index: news
  350. refresh: true
  351. body: |'''
  352. // Make h5n1 strongly connected to bird flu
  353. for (int i = 0; i < 100; i++) {
  354. buildRestTests.setups['news'] += """
  355. {"index":{}}
  356. {"source": "very_relevant_$i", "content": "bird flu h5n1"}"""
  357. }
  358. for (int i = 0; i < 100; i++) {
  359. buildRestTests.setups['news'] += """
  360. {"index":{}}
  361. {"source": "filler_$i", "content": "bird dupFiller "}"""
  362. }
  363. for (int i = 0; i < 100; i++) {
  364. buildRestTests.setups['news'] += """
  365. {"index":{}}
  366. {"source": "filler_$i", "content": "flu dupFiller "}"""
  367. }
  368. for (int i = 0; i < 20; i++) {
  369. buildRestTests.setups['news'] += """
  370. {"index":{}}
  371. {"source": "partially_relevant_$i", "content": "elasticsearch dupFiller dupFiller dupFiller dupFiller pozmantier"}"""
  372. }
  373. for (int i = 0; i < 10; i++) {
  374. buildRestTests.setups['news'] += """
  375. {"index":{}}
  376. {"source": "partially_relevant_$i", "content": "elasticsearch logstash kibana"}"""
  377. }
  378. buildRestTests.setups['news'] += """
  379. """
  380. // Used by some aggregations
  381. buildRestTests.setups['exams'] = '''
  382. - do:
  383. indices.create:
  384. index: exams
  385. body:
  386. settings:
  387. number_of_shards: 1
  388. number_of_replicas: 1
  389. mappings:
  390. properties:
  391. grade:
  392. type: byte
  393. - do:
  394. bulk:
  395. index: exams
  396. refresh: true
  397. body: |
  398. {"index":{}}
  399. {"grade": 100, "weight": 2}
  400. {"index":{}}
  401. {"grade": 50, "weight": 3}'''
  402. buildRestTests.setups['stored_example_script'] = '''
  403. # Simple script to load a field. Not really a good example, but a simple one.
  404. - do:
  405. put_script:
  406. id: "my_script"
  407. body: { "script": { "lang": "painless", "source": "doc[params.field].value" } }
  408. - match: { acknowledged: true }
  409. '''
  410. buildRestTests.setups['stored_scripted_metric_script'] = '''
  411. - do:
  412. put_script:
  413. id: "my_init_script"
  414. body: { "script": { "lang": "painless", "source": "state.transactions = []" } }
  415. - match: { acknowledged: true }
  416. - do:
  417. put_script:
  418. id: "my_map_script"
  419. body: { "script": { "lang": "painless", "source": "state.transactions.add(doc.type.value == 'sale' ? doc.amount.value : -1 * doc.amount.value)" } }
  420. - match: { acknowledged: true }
  421. - do:
  422. put_script:
  423. id: "my_combine_script"
  424. body: { "script": { "lang": "painless", "source": "double profit = 0;for (t in state.transactions) { profit += t; } return profit" } }
  425. - match: { acknowledged: true }
  426. - do:
  427. put_script:
  428. id: "my_reduce_script"
  429. body: { "script": { "lang": "painless", "source": "double profit = 0;for (a in states) { profit += a; } return profit" } }
  430. - match: { acknowledged: true }
  431. '''
  432. // Used by analyze api
  433. buildRestTests.setups['analyze_sample'] = '''
  434. - do:
  435. indices.create:
  436. index: analyze_sample
  437. body:
  438. settings:
  439. number_of_shards: 1
  440. number_of_replicas: 0
  441. analysis:
  442. normalizer:
  443. my_normalizer:
  444. type: custom
  445. filter: [lowercase]
  446. mappings:
  447. properties:
  448. obj1.field1:
  449. type: text'''
  450. // Used by percentile/percentile-rank aggregations
  451. buildRestTests.setups['latency'] = '''
  452. - do:
  453. indices.create:
  454. index: latency
  455. body:
  456. settings:
  457. number_of_shards: 1
  458. number_of_replicas: 1
  459. mappings:
  460. properties:
  461. load_time:
  462. type: long
  463. - do:
  464. bulk:
  465. index: latency
  466. refresh: true
  467. body: |'''
  468. for (int i = 0; i < 100; i++) {
  469. def value = i
  470. if (i % 10) {
  471. value = i*10
  472. }
  473. buildRestTests.setups['latency'] += """
  474. {"index":{}}
  475. {"load_time": "$value"}"""
  476. }
  477. // Used by iprange agg
  478. buildRestTests.setups['iprange'] = '''
  479. - do:
  480. indices.create:
  481. index: ip_addresses
  482. body:
  483. settings:
  484. number_of_shards: 1
  485. number_of_replicas: 1
  486. mappings:
  487. properties:
  488. ip:
  489. type: ip
  490. - do:
  491. bulk:
  492. index: ip_addresses
  493. refresh: true
  494. body: |'''
  495. for (int i = 0; i < 255; i++) {
  496. buildRestTests.setups['iprange'] += """
  497. {"index":{}}
  498. {"ip": "10.0.0.$i"}"""
  499. }
  500. for (int i = 0; i < 5; i++) {
  501. buildRestTests.setups['iprange'] += """
  502. {"index":{}}
  503. {"ip": "9.0.0.$i"}"""
  504. buildRestTests.setups['iprange'] += """
  505. {"index":{}}
  506. {"ip": "11.0.0.$i"}"""
  507. buildRestTests.setups['iprange'] += """
  508. {"index":{}}
  509. {"ip": "12.0.0.$i"}"""
  510. }
  511. // Used by SQL because it looks SQL-ish
  512. buildRestTests.setups['library'] = '''
  513. - do:
  514. indices.create:
  515. include_type_name: true
  516. index: library
  517. body:
  518. settings:
  519. number_of_shards: 1
  520. number_of_replicas: 1
  521. mappings:
  522. book:
  523. properties:
  524. name:
  525. type: text
  526. fields:
  527. keyword:
  528. type: keyword
  529. author:
  530. type: text
  531. fields:
  532. keyword:
  533. type: keyword
  534. release_date:
  535. type: date
  536. page_count:
  537. type: short
  538. - do:
  539. bulk:
  540. index: library
  541. type: book
  542. refresh: true
  543. body: |
  544. {"index":{"_id": "Leviathan Wakes"}}
  545. {"name": "Leviathan Wakes", "author": "James S.A. Corey", "release_date": "2011-06-02", "page_count": 561}
  546. {"index":{"_id": "Hyperion"}}
  547. {"name": "Hyperion", "author": "Dan Simmons", "release_date": "1989-05-26", "page_count": 482}
  548. {"index":{"_id": "Dune"}}
  549. {"name": "Dune", "author": "Frank Herbert", "release_date": "1965-06-01", "page_count": 604}
  550. {"index":{"_id": "Dune Messiah"}}
  551. {"name": "Dune Messiah", "author": "Frank Herbert", "release_date": "1969-10-15", "page_count": 331}
  552. {"index":{"_id": "Children of Dune"}}
  553. {"name": "Children of Dune", "author": "Frank Herbert", "release_date": "1976-04-21", "page_count": 408}
  554. {"index":{"_id": "God Emperor of Dune"}}
  555. {"name": "God Emperor of Dune", "author": "Frank Herbert", "release_date": "1981-05-28", "page_count": 454}
  556. {"index":{"_id": "Consider Phlebas"}}
  557. {"name": "Consider Phlebas", "author": "Iain M. Banks", "release_date": "1987-04-23", "page_count": 471}
  558. {"index":{"_id": "Pandora's Star"}}
  559. {"name": "Pandora's Star", "author": "Peter F. Hamilton", "release_date": "2004-03-02", "page_count": 768}
  560. {"index":{"_id": "Revelation Space"}}
  561. {"name": "Revelation Space", "author": "Alastair Reynolds", "release_date": "2000-03-15", "page_count": 585}
  562. {"index":{"_id": "A Fire Upon the Deep"}}
  563. {"name": "A Fire Upon the Deep", "author": "Vernor Vinge", "release_date": "1992-06-01", "page_count": 613}
  564. {"index":{"_id": "Ender's Game"}}
  565. {"name": "Ender's Game", "author": "Orson Scott Card", "release_date": "1985-06-01", "page_count": 324}
  566. {"index":{"_id": "1984"}}
  567. {"name": "1984", "author": "George Orwell", "release_date": "1985-06-01", "page_count": 328}
  568. {"index":{"_id": "Fahrenheit 451"}}
  569. {"name": "Fahrenheit 451", "author": "Ray Bradbury", "release_date": "1953-10-15", "page_count": 227}
  570. {"index":{"_id": "Brave New World"}}
  571. {"name": "Brave New World", "author": "Aldous Huxley", "release_date": "1932-06-01", "page_count": 268}
  572. {"index":{"_id": "Foundation"}}
  573. {"name": "Foundation", "author": "Isaac Asimov", "release_date": "1951-06-01", "page_count": 224}
  574. {"index":{"_id": "The Giver"}}
  575. {"name": "The Giver", "author": "Lois Lowry", "release_date": "1993-04-26", "page_count": 208}
  576. {"index":{"_id": "Slaughterhouse-Five"}}
  577. {"name": "Slaughterhouse-Five", "author": "Kurt Vonnegut", "release_date": "1969-06-01", "page_count": 275}
  578. {"index":{"_id": "The Hitchhiker's Guide to the Galaxy"}}
  579. {"name": "The Hitchhiker's Guide to the Galaxy", "author": "Douglas Adams", "release_date": "1979-10-12", "page_count": 180}
  580. {"index":{"_id": "Snow Crash"}}
  581. {"name": "Snow Crash", "author": "Neal Stephenson", "release_date": "1992-06-01", "page_count": 470}
  582. {"index":{"_id": "Neuromancer"}}
  583. {"name": "Neuromancer", "author": "William Gibson", "release_date": "1984-07-01", "page_count": 271}
  584. {"index":{"_id": "The Handmaid's Tale"}}
  585. {"name": "The Handmaid's Tale", "author": "Margaret Atwood", "release_date": "1985-06-01", "page_count": 311}
  586. {"index":{"_id": "Starship Troopers"}}
  587. {"name": "Starship Troopers", "author": "Robert A. Heinlein", "release_date": "1959-12-01", "page_count": 335}
  588. {"index":{"_id": "The Left Hand of Darkness"}}
  589. {"name": "The Left Hand of Darkness", "author": "Ursula K. Le Guin", "release_date": "1969-06-01", "page_count": 304}
  590. {"index":{"_id": "The Moon is a Harsh Mistress"}}
  591. {"name": "The Moon is a Harsh Mistress", "author": "Robert A. Heinlein", "release_date": "1966-04-01", "page_count": 288}
  592. '''
  593. buildRestTests.setups['sensor_rollup_job'] = '''
  594. - do:
  595. indices.create:
  596. index: sensor-1
  597. body:
  598. settings:
  599. number_of_shards: 1
  600. number_of_replicas: 0
  601. mappings:
  602. properties:
  603. timestamp:
  604. type: date
  605. temperature:
  606. type: long
  607. voltage:
  608. type: float
  609. node:
  610. type: keyword
  611. - do:
  612. raw:
  613. method: PUT
  614. path: _rollup/job/sensor
  615. body: >
  616. {
  617. "index_pattern": "sensor-*",
  618. "rollup_index": "sensor_rollup",
  619. "cron": "*/30 * * * * ?",
  620. "page_size" :1000,
  621. "groups" : {
  622. "date_histogram": {
  623. "field": "timestamp",
  624. "fixed_interval": "1h",
  625. "delay": "7d"
  626. },
  627. "terms": {
  628. "fields": ["node"]
  629. }
  630. },
  631. "metrics": [
  632. {
  633. "field": "temperature",
  634. "metrics": ["min", "max", "sum"]
  635. },
  636. {
  637. "field": "voltage",
  638. "metrics": ["avg"]
  639. }
  640. ]
  641. }
  642. '''
  643. buildRestTests.setups['sensor_started_rollup_job'] = '''
  644. - do:
  645. indices.create:
  646. index: sensor-1
  647. body:
  648. settings:
  649. number_of_shards: 1
  650. number_of_replicas: 0
  651. mappings:
  652. properties:
  653. timestamp:
  654. type: date
  655. temperature:
  656. type: long
  657. voltage:
  658. type: float
  659. node:
  660. type: keyword
  661. - do:
  662. bulk:
  663. index: sensor-1
  664. refresh: true
  665. body: |
  666. {"index":{}}
  667. {"timestamp": 1516729294000, "temperature": 200, "voltage": 5.2, "node": "a"}
  668. {"index":{}}
  669. {"timestamp": 1516642894000, "temperature": 201, "voltage": 5.8, "node": "b"}
  670. {"index":{}}
  671. {"timestamp": 1516556494000, "temperature": 202, "voltage": 5.1, "node": "a"}
  672. {"index":{}}
  673. {"timestamp": 1516470094000, "temperature": 198, "voltage": 5.6, "node": "b"}
  674. {"index":{}}
  675. {"timestamp": 1516383694000, "temperature": 200, "voltage": 4.2, "node": "c"}
  676. {"index":{}}
  677. {"timestamp": 1516297294000, "temperature": 202, "voltage": 4.0, "node": "c"}
  678. - do:
  679. raw:
  680. method: PUT
  681. path: _rollup/job/sensor
  682. body: >
  683. {
  684. "index_pattern": "sensor-*",
  685. "rollup_index": "sensor_rollup",
  686. "cron": "* * * * * ?",
  687. "page_size" :1000,
  688. "groups" : {
  689. "date_histogram": {
  690. "field": "timestamp",
  691. "fixed_interval": "1h",
  692. "delay": "7d"
  693. },
  694. "terms": {
  695. "fields": ["node"]
  696. }
  697. },
  698. "metrics": [
  699. {
  700. "field": "temperature",
  701. "metrics": ["min", "max", "sum"]
  702. },
  703. {
  704. "field": "voltage",
  705. "metrics": ["avg"]
  706. }
  707. ]
  708. }
  709. - do:
  710. raw:
  711. method: POST
  712. path: _rollup/job/sensor/_start
  713. '''
  714. buildRestTests.setups['sensor_index'] = '''
  715. - do:
  716. indices.create:
  717. index: sensor-1
  718. body:
  719. settings:
  720. number_of_shards: 1
  721. number_of_replicas: 0
  722. mappings:
  723. properties:
  724. timestamp:
  725. type: date
  726. temperature:
  727. type: long
  728. voltage:
  729. type: float
  730. node:
  731. type: keyword
  732. load:
  733. type: double
  734. net_in:
  735. type: long
  736. net_out:
  737. type: long
  738. hostname:
  739. type: keyword
  740. datacenter:
  741. type: keyword
  742. '''
  743. buildRestTests.setups['sensor_prefab_data'] = '''
  744. - do:
  745. indices.create:
  746. index: sensor-1
  747. body:
  748. settings:
  749. number_of_shards: 1
  750. number_of_replicas: 0
  751. mappings:
  752. properties:
  753. timestamp:
  754. type: date
  755. temperature:
  756. type: long
  757. voltage:
  758. type: float
  759. node:
  760. type: keyword
  761. - do:
  762. indices.create:
  763. index: sensor_rollup
  764. body:
  765. settings:
  766. number_of_shards: 1
  767. number_of_replicas: 0
  768. mappings:
  769. properties:
  770. node.terms.value:
  771. type: keyword
  772. temperature.sum.value:
  773. type: double
  774. temperature.max.value:
  775. type: double
  776. temperature.min.value:
  777. type: double
  778. timestamp.date_histogram.time_zone:
  779. type: keyword
  780. timestamp.date_histogram.interval:
  781. type: keyword
  782. timestamp.date_histogram.timestamp:
  783. type: date
  784. timestamp.date_histogram._count:
  785. type: long
  786. voltage.avg.value:
  787. type: double
  788. voltage.avg._count:
  789. type: long
  790. _rollup.id:
  791. type: keyword
  792. _rollup.version:
  793. type: long
  794. _meta:
  795. _rollup:
  796. sensor:
  797. cron: "* * * * * ?"
  798. rollup_index: "sensor_rollup"
  799. index_pattern: "sensor-*"
  800. timeout: "20s"
  801. page_size: 1000
  802. groups:
  803. date_histogram:
  804. delay: "7d"
  805. field: "timestamp"
  806. fixed_interval: "60m"
  807. time_zone: "UTC"
  808. terms:
  809. fields:
  810. - "node"
  811. id: sensor
  812. metrics:
  813. - field: "temperature"
  814. metrics:
  815. - min
  816. - max
  817. - sum
  818. - field: "voltage"
  819. metrics:
  820. - avg
  821. - do:
  822. bulk:
  823. index: sensor_rollup
  824. refresh: true
  825. body: |
  826. {"index":{}}
  827. {"node.terms.value":"b","temperature.sum.value":201.0,"temperature.max.value":201.0,"timestamp.date_histogram.time_zone":"UTC","temperature.min.value":201.0,"timestamp.date_histogram._count":1,"timestamp.date_histogram.interval":"1h","_rollup.computed":["temperature.sum","temperature.min","voltage.avg","temperature.max","node.terms","timestamp.date_histogram"],"voltage.avg.value":5.800000190734863,"node.terms._count":1,"_rollup.version":1,"timestamp.date_histogram.timestamp":1516640400000,"voltage.avg._count":1.0,"_rollup.id":"sensor"}
  828. {"index":{}}
  829. {"node.terms.value":"c","temperature.sum.value":200.0,"temperature.max.value":200.0,"timestamp.date_histogram.time_zone":"UTC","temperature.min.value":200.0,"timestamp.date_histogram._count":1,"timestamp.date_histogram.interval":"1h","_rollup.computed":["temperature.sum","temperature.min","voltage.avg","temperature.max","node.terms","timestamp.date_histogram"],"voltage.avg.value":4.199999809265137,"node.terms._count":1,"_rollup.version":1,"timestamp.date_histogram.timestamp":1516381200000,"voltage.avg._count":1.0,"_rollup.id":"sensor"}
  830. {"index":{}}
  831. {"node.terms.value":"a","temperature.sum.value":202.0,"temperature.max.value":202.0,"timestamp.date_histogram.time_zone":"UTC","temperature.min.value":202.0,"timestamp.date_histogram._count":1,"timestamp.date_histogram.interval":"1h","_rollup.computed":["temperature.sum","temperature.min","voltage.avg","temperature.max","node.terms","timestamp.date_histogram"],"voltage.avg.value":5.099999904632568,"node.terms._count":1,"_rollup.version":1,"timestamp.date_histogram.timestamp":1516554000000,"voltage.avg._count":1.0,"_rollup.id":"sensor"}
  832. {"index":{}}
  833. {"node.terms.value":"a","temperature.sum.value":200.0,"temperature.max.value":200.0,"timestamp.date_histogram.time_zone":"UTC","temperature.min.value":200.0,"timestamp.date_histogram._count":1,"timestamp.date_histogram.interval":"1h","_rollup.computed":["temperature.sum","temperature.min","voltage.avg","temperature.max","node.terms","timestamp.date_histogram"],"voltage.avg.value":5.199999809265137,"node.terms._count":1,"_rollup.version":1,"timestamp.date_histogram.timestamp":1516726800000,"voltage.avg._count":1.0,"_rollup.id":"sensor"}
  834. {"index":{}}
  835. {"node.terms.value":"b","temperature.sum.value":198.0,"temperature.max.value":198.0,"timestamp.date_histogram.time_zone":"UTC","temperature.min.value":198.0,"timestamp.date_histogram._count":1,"timestamp.date_histogram.interval":"1h","_rollup.computed":["temperature.sum","temperature.min","voltage.avg","temperature.max","node.terms","timestamp.date_histogram"],"voltage.avg.value":5.599999904632568,"node.terms._count":1,"_rollup.version":1,"timestamp.date_histogram.timestamp":1516467600000,"voltage.avg._count":1.0,"_rollup.id":"sensor"}
  836. {"index":{}}
  837. {"node.terms.value":"c","temperature.sum.value":202.0,"temperature.max.value":202.0,"timestamp.date_histogram.time_zone":"UTC","temperature.min.value":202.0,"timestamp.date_histogram._count":1,"timestamp.date_histogram.interval":"1h","_rollup.computed":["temperature.sum","temperature.min","voltage.avg","temperature.max","node.terms","timestamp.date_histogram"],"voltage.avg.value":4.0,"node.terms._count":1,"_rollup.version":1,"timestamp.date_histogram.timestamp":1516294800000,"voltage.avg._count":1.0,"_rollup.id":"sensor"}
  838. '''
  839. buildRestTests.setups['sample_job'] = '''
  840. - do:
  841. ml.put_job:
  842. job_id: "sample_job"
  843. body: >
  844. {
  845. "description" : "Very basic job",
  846. "analysis_config" : {
  847. "bucket_span":"10m",
  848. "detectors" :[
  849. {
  850. "function": "count"
  851. }
  852. ]},
  853. "data_description" : {
  854. "time_field":"timestamp",
  855. "time_format": "epoch_ms"
  856. }
  857. }
  858. '''
  859. buildRestTests.setups['farequote_index'] = '''
  860. - do:
  861. indices.create:
  862. index: farequote
  863. body:
  864. settings:
  865. number_of_shards: 1
  866. number_of_replicas: 0
  867. mappings:
  868. metric:
  869. properties:
  870. time:
  871. type: date
  872. responsetime:
  873. type: float
  874. airline:
  875. type: keyword
  876. doc_count:
  877. type: integer
  878. '''
  879. buildRestTests.setups['farequote_data'] = buildRestTests.setups['farequote_index'] + '''
  880. - do:
  881. bulk:
  882. index: farequote
  883. type: metric
  884. refresh: true
  885. body: |
  886. {"index": {"_id":"1"}}
  887. {"airline":"JZA","responsetime":990.4628,"time":"2016-02-07T00:00:00+0000", "doc_count": 5}
  888. {"index": {"_id":"2"}}
  889. {"airline":"JBU","responsetime":877.5927,"time":"2016-02-07T00:00:00+0000", "doc_count": 23}
  890. {"index": {"_id":"3"}}
  891. {"airline":"KLM","responsetime":1355.4812,"time":"2016-02-07T00:00:00+0000", "doc_count": 42}
  892. '''
  893. buildRestTests.setups['farequote_job'] = buildRestTests.setups['farequote_data'] + '''
  894. - do:
  895. ml.put_job:
  896. job_id: "farequote"
  897. body: >
  898. {
  899. "analysis_config": {
  900. "bucket_span": "60m",
  901. "detectors": [{
  902. "function": "mean",
  903. "field_name": "responsetime",
  904. "by_field_name": "airline"
  905. }],
  906. "summary_count_field_name": "doc_count"
  907. },
  908. "data_description": {
  909. "time_field": "time"
  910. }
  911. }
  912. '''
  913. buildRestTests.setups['farequote_datafeed'] = buildRestTests.setups['farequote_job'] + '''
  914. - do:
  915. ml.put_datafeed:
  916. datafeed_id: "datafeed-farequote"
  917. body: >
  918. {
  919. "job_id":"farequote",
  920. "indexes":"farequote"
  921. }
  922. '''
  923. buildRestTests.setups['server_metrics_index'] = '''
  924. - do:
  925. indices.create:
  926. index: server-metrics
  927. body:
  928. settings:
  929. number_of_shards: 1
  930. number_of_replicas: 0
  931. mappings:
  932. metric:
  933. properties:
  934. timestamp:
  935. type: date
  936. total:
  937. type: long
  938. '''
  939. buildRestTests.setups['server_metrics_data'] = buildRestTests.setups['server_metrics_index'] + '''
  940. - do:
  941. bulk:
  942. index: server-metrics
  943. type: metric
  944. refresh: true
  945. body: |
  946. {"index": {"_id":"1177"}}
  947. {"timestamp":"2017-03-23T13:00:00","total":40476}
  948. {"index": {"_id":"1178"}}
  949. {"timestamp":"2017-03-23T13:00:00","total":15287}
  950. {"index": {"_id":"1179"}}
  951. {"timestamp":"2017-03-23T13:00:00","total":-776}
  952. {"index": {"_id":"1180"}}
  953. {"timestamp":"2017-03-23T13:00:00","total":11366}
  954. {"index": {"_id":"1181"}}
  955. {"timestamp":"2017-03-23T13:00:00","total":3606}
  956. {"index": {"_id":"1182"}}
  957. {"timestamp":"2017-03-23T13:00:00","total":19006}
  958. {"index": {"_id":"1183"}}
  959. {"timestamp":"2017-03-23T13:00:00","total":38613}
  960. {"index": {"_id":"1184"}}
  961. {"timestamp":"2017-03-23T13:00:00","total":19516}
  962. {"index": {"_id":"1185"}}
  963. {"timestamp":"2017-03-23T13:00:00","total":-258}
  964. {"index": {"_id":"1186"}}
  965. {"timestamp":"2017-03-23T13:00:00","total":9551}
  966. {"index": {"_id":"1187"}}
  967. {"timestamp":"2017-03-23T13:00:00","total":11217}
  968. {"index": {"_id":"1188"}}
  969. {"timestamp":"2017-03-23T13:00:00","total":22557}
  970. {"index": {"_id":"1189"}}
  971. {"timestamp":"2017-03-23T13:00:00","total":40508}
  972. {"index": {"_id":"1190"}}
  973. {"timestamp":"2017-03-23T13:00:00","total":11887}
  974. {"index": {"_id":"1191"}}
  975. {"timestamp":"2017-03-23T13:00:00","total":31659}
  976. '''
  977. buildRestTests.setups['server_metrics_job'] = buildRestTests.setups['server_metrics_data'] + '''
  978. - do:
  979. ml.put_job:
  980. job_id: "total-requests"
  981. body: >
  982. {
  983. "description" : "Total sum of requests",
  984. "analysis_config" : {
  985. "bucket_span":"10m",
  986. "detectors" :[
  987. {
  988. "detector_description": "Sum of total",
  989. "function": "sum",
  990. "field_name": "total"
  991. }
  992. ]},
  993. "data_description" : {
  994. "time_field":"timestamp",
  995. "time_format": "epoch_ms"
  996. }
  997. }
  998. '''
  999. buildRestTests.setups['server_metrics_datafeed'] = buildRestTests.setups['server_metrics_job'] + '''
  1000. - do:
  1001. ml.put_datafeed:
  1002. datafeed_id: "datafeed-total-requests"
  1003. body: >
  1004. {
  1005. "job_id":"total-requests",
  1006. "indexes":"server-metrics"
  1007. }
  1008. '''
  1009. buildRestTests.setups['server_metrics_openjob'] = buildRestTests.setups['server_metrics_datafeed'] + '''
  1010. - do:
  1011. ml.open_job:
  1012. job_id: "total-requests"
  1013. '''
  1014. buildRestTests.setups['server_metrics_startdf'] = buildRestTests.setups['server_metrics_openjob'] + '''
  1015. - do:
  1016. ml.start_datafeed:
  1017. datafeed_id: "datafeed-total-requests"
  1018. '''
  1019. buildRestTests.setups['calendar_outages'] = '''
  1020. - do:
  1021. ml.put_calendar:
  1022. calendar_id: "planned-outages"
  1023. '''
  1024. buildRestTests.setups['calendar_outages_addevent'] = buildRestTests.setups['calendar_outages'] + '''
  1025. - do:
  1026. ml.post_calendar_events:
  1027. calendar_id: "planned-outages"
  1028. body: >
  1029. { "description": "event 1", "start_time": "2017-12-01T00:00:00Z", "end_time": "2017-12-02T00:00:00Z", "calendar_id": "planned-outages" }
  1030. '''
  1031. buildRestTests.setups['calendar_outages_openjob'] = buildRestTests.setups['server_metrics_openjob'] + '''
  1032. - do:
  1033. ml.put_calendar:
  1034. calendar_id: "planned-outages"
  1035. '''
  1036. buildRestTests.setups['calendar_outages_addjob'] = buildRestTests.setups['server_metrics_openjob'] + '''
  1037. - do:
  1038. ml.put_calendar:
  1039. calendar_id: "planned-outages"
  1040. body: >
  1041. {
  1042. "job_ids": ["total-requests"]
  1043. }
  1044. '''
  1045. buildRestTests.setups['calendar_outages_addevent'] = buildRestTests.setups['calendar_outages_addjob'] + '''
  1046. - do:
  1047. ml.post_calendar_events:
  1048. calendar_id: "planned-outages"
  1049. body: >
  1050. { "events" : [
  1051. { "description": "event 1", "start_time": "1513641600000", "end_time": "1513728000000"},
  1052. { "description": "event 2", "start_time": "1513814400000", "end_time": "1513900800000"},
  1053. { "description": "event 3", "start_time": "1514160000000", "end_time": "1514246400000"}
  1054. ]}
  1055. '''
  1056. // used by median absolute deviation aggregation
  1057. buildRestTests.setups['reviews'] = '''
  1058. - do:
  1059. indices.create:
  1060. index: reviews
  1061. body:
  1062. settings:
  1063. number_of_shards: 1
  1064. number_of_replicas: 0
  1065. mappings:
  1066. properties:
  1067. product:
  1068. type: keyword
  1069. rating:
  1070. type: long
  1071. - do:
  1072. bulk:
  1073. index: reviews
  1074. refresh: true
  1075. body: |
  1076. {"index": {"_id": "1"}}
  1077. {"product": "widget-foo", "rating": 1}
  1078. {"index": {"_id": "2"}}
  1079. {"product": "widget-foo", "rating": 5}
  1080. '''
  1081. buildRestTests.setups['remote_cluster'] = buildRestTests.setups['host'] + '''
  1082. - do:
  1083. cluster.put_settings:
  1084. body:
  1085. persistent:
  1086. cluster.remote.remote_cluster.seeds: $transport_host
  1087. '''
  1088. buildRestTests.setups['remote_cluster_and_leader_index'] = buildRestTests.setups['remote_cluster'] + '''
  1089. - do:
  1090. indices.create:
  1091. index: leader_index
  1092. body:
  1093. settings:
  1094. index.number_of_replicas: 0
  1095. index.number_of_shards: 1
  1096. index.soft_deletes.enabled: true
  1097. '''
  1098. buildRestTests.setups['seats'] = '''
  1099. - do:
  1100. indices.create:
  1101. index: seats
  1102. body:
  1103. settings:
  1104. number_of_shards: 1
  1105. number_of_replicas: 0
  1106. mappings:
  1107. properties:
  1108. theatre:
  1109. type: keyword
  1110. cost:
  1111. type: long
  1112. row:
  1113. type: long
  1114. number:
  1115. type: long
  1116. sold:
  1117. type: boolean
  1118. - do:
  1119. bulk:
  1120. index: seats
  1121. refresh: true
  1122. body: |
  1123. {"index":{"_id": "1"}}
  1124. {"theatre": "Skyline", "cost": 37, "row": 1, "number": 7, "sold": false}
  1125. {"index":{"_id": "2"}}
  1126. {"theatre": "Graye", "cost": 30, "row": 3, "number": 5, "sold": false}
  1127. {"index":{"_id": "3"}}
  1128. {"theatre": "Graye", "cost": 33, "row": 2, "number": 6, "sold": false}
  1129. {"index":{"_id": "4"}}
  1130. {"theatre": "Skyline", "cost": 20, "row": 5, "number": 2, "sold": false}'''
  1131. buildRestTests.setups['kibana_sample_data_ecommerce'] = '''
  1132. - do:
  1133. indices.create:
  1134. index: kibana_sample_data_ecommerce
  1135. body:
  1136. settings:
  1137. number_of_shards: 1
  1138. number_of_replicas: 0
  1139. '''
  1140. buildRestTests.setups['simple_kibana_continuous_pivot'] = buildRestTests.setups['kibana_sample_data_ecommerce'] + '''
  1141. - do:
  1142. raw:
  1143. method: PUT
  1144. path: _data_frame/transforms/simple-kibana-ecomm-pivot
  1145. body: >
  1146. {
  1147. "source": {
  1148. "index": "kibana_sample_data_ecommerce",
  1149. "query": {
  1150. "term": {
  1151. "geoip.continent_name": {
  1152. "value": "Asia"
  1153. }
  1154. }
  1155. }
  1156. },
  1157. "pivot": {
  1158. "group_by": {
  1159. "customer_id": {
  1160. "terms": {
  1161. "field": "customer_id"
  1162. }
  1163. }
  1164. },
  1165. "aggregations": {
  1166. "max_price": {
  1167. "max": {
  1168. "field": "taxful_total_price"
  1169. }
  1170. }
  1171. }
  1172. },
  1173. "description": "Maximum priced ecommerce data",
  1174. "dest": {
  1175. "index": "kibana_sample_data_ecommerce_transform",
  1176. "pipeline": "add_timestamp_pipeline"
  1177. },
  1178. "frequency": "5m",
  1179. "sync": {
  1180. "time": {
  1181. "field": "order_date",
  1182. "delay": "60s"
  1183. }
  1184. }
  1185. }
  1186. '''
  1187. buildRestTests.setups['setup_logdata'] = '''
  1188. - do:
  1189. indices.create:
  1190. index: logdata
  1191. body:
  1192. settings:
  1193. number_of_shards: 1
  1194. number_of_replicas: 1
  1195. mappings:
  1196. properties:
  1197. grade:
  1198. type: byte
  1199. - do:
  1200. bulk:
  1201. index: logdata
  1202. refresh: true
  1203. body: |
  1204. {"index":{}}
  1205. {"grade": 100, "weight": 2}
  1206. {"index":{}}
  1207. {"grade": 50, "weight": 3}
  1208. '''
  1209. buildRestTests.setups['logdata_job'] = buildRestTests.setups['setup_logdata'] + '''
  1210. - do:
  1211. ml.put_data_frame_analytics:
  1212. id: "loganalytics"
  1213. body: >
  1214. {
  1215. "source": {
  1216. "index": "logdata"
  1217. },
  1218. "dest": {
  1219. "index": "logdata_out"
  1220. },
  1221. "analysis": {
  1222. "outlier_detection": {}
  1223. }
  1224. }
  1225. '''
  1226. // Used by snapshot lifecycle management docs
  1227. buildRestTests.setups['setup-repository'] = '''
  1228. - do:
  1229. snapshot.create_repository:
  1230. repository: my_repository
  1231. body:
  1232. type: fs
  1233. settings:
  1234. location: buildDir/cluster/shared/repo
  1235. '''