build.gradle 44 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282
  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. listConsoleCandidates.docs = buildRestTests.docs
  87. Closure setupTwitter = { String name, int count ->
  88. buildRestTests.setups[name] = '''
  89. - do:
  90. indices.create:
  91. index: twitter
  92. body:
  93. settings:
  94. number_of_shards: 1
  95. number_of_replicas: 1
  96. mappings:
  97. properties:
  98. user:
  99. type: keyword
  100. doc_values: true
  101. date:
  102. type: date
  103. likes:
  104. type: long
  105. - do:
  106. bulk:
  107. index: twitter
  108. refresh: true
  109. body: |'''
  110. for (int i = 0; i < count; i++) {
  111. String user, text
  112. if (i == 0) {
  113. user = 'kimchy'
  114. text = 'trying out Elasticsearch'
  115. } else {
  116. user = 'test'
  117. text = "some message with the number $i"
  118. }
  119. buildRestTests.setups[name] += """
  120. {"index":{"_id": "$i"}}
  121. {"user": "$user", "message": "$text", "date": "2009-11-15T14:12:12", "likes": $i}"""
  122. }
  123. }
  124. setupTwitter('twitter', 5)
  125. setupTwitter('big_twitter', 120)
  126. setupTwitter('huge_twitter', 1200)
  127. buildRestTests.setups['host'] = '''
  128. # Fetch the http host. We use the host of the master because we know there will always be a master.
  129. - do:
  130. cluster.state: {}
  131. - set: { master_node: master }
  132. - do:
  133. nodes.info:
  134. metric: [ http, transport ]
  135. - set: {nodes.$master.http.publish_address: host}
  136. - set: {nodes.$master.transport.publish_address: transport_host}
  137. '''
  138. buildRestTests.setups['node'] = '''
  139. # Fetch the node name. We use the host of the master because we know there will always be a master.
  140. - do:
  141. cluster.state: {}
  142. - is_true: master_node
  143. - set: { master_node: node_name }
  144. '''
  145. // Used by scripted metric docs
  146. buildRestTests.setups['ledger'] = '''
  147. - do:
  148. indices.create:
  149. index: ledger
  150. body:
  151. settings:
  152. number_of_shards: 2
  153. number_of_replicas: 1
  154. mappings:
  155. properties:
  156. type:
  157. type: keyword
  158. amount:
  159. type: double
  160. - do:
  161. bulk:
  162. index: ledger
  163. refresh: true
  164. body: |
  165. {"index":{}}
  166. {"date": "2015/01/01 00:00:00", "amount": 200, "type": "sale", "description": "something"}
  167. {"index":{}}
  168. {"date": "2015/01/01 00:00:00", "amount": 10, "type": "expense", "decription": "another thing"}
  169. {"index":{}}
  170. {"date": "2015/01/01 00:00:00", "amount": 150, "type": "sale", "description": "blah"}
  171. {"index":{}}
  172. {"date": "2015/01/01 00:00:00", "amount": 50, "type": "expense", "description": "cost of blah"}
  173. {"index":{}}
  174. {"date": "2015/01/01 00:00:00", "amount": 50, "type": "expense", "description": "advertisement"}'''
  175. // Used by aggregation docs
  176. buildRestTests.setups['sales'] = '''
  177. - do:
  178. indices.create:
  179. index: sales
  180. body:
  181. settings:
  182. number_of_shards: 2
  183. number_of_replicas: 1
  184. mappings:
  185. properties:
  186. type:
  187. type: keyword
  188. - do:
  189. bulk:
  190. index: sales
  191. refresh: true
  192. body: |
  193. {"index":{}}
  194. {"date": "2015/01/01 00:00:00", "price": 200, "promoted": true, "rating": 1, "type": "hat"}
  195. {"index":{}}
  196. {"date": "2015/01/01 00:00:00", "price": 200, "promoted": true, "rating": 1, "type": "t-shirt"}
  197. {"index":{}}
  198. {"date": "2015/01/01 00:00:00", "price": 150, "promoted": true, "rating": 5, "type": "bag"}
  199. {"index":{}}
  200. {"date": "2015/02/01 00:00:00", "price": 50, "promoted": false, "rating": 1, "type": "hat"}
  201. {"index":{}}
  202. {"date": "2015/02/01 00:00:00", "price": 10, "promoted": true, "rating": 4, "type": "t-shirt"}
  203. {"index":{}}
  204. {"date": "2015/03/01 00:00:00", "price": 200, "promoted": true, "rating": 1, "type": "hat"}
  205. {"index":{}}
  206. {"date": "2015/03/01 00:00:00", "price": 175, "promoted": false, "rating": 2, "type": "t-shirt"}'''
  207. // Used by cumulative cardinality aggregation docs
  208. buildRestTests.setups['user_hits'] = '''
  209. - do:
  210. indices.create:
  211. index: user_hits
  212. body:
  213. settings:
  214. number_of_shards: 1
  215. number_of_replicas: 0
  216. mappings:
  217. properties:
  218. user_id:
  219. type: keyword
  220. timestamp:
  221. type: date
  222. - do:
  223. bulk:
  224. index: user_hits
  225. refresh: true
  226. body: |
  227. {"index":{}}
  228. {"timestamp": "2019-01-01T13:00:00", "user_id": "1"}
  229. {"index":{}}
  230. {"timestamp": "2019-01-01T13:00:00", "user_id": "2"}
  231. {"index":{}}
  232. {"timestamp": "2019-01-02T13:00:00", "user_id": "1"}
  233. {"index":{}}
  234. {"timestamp": "2019-01-02T13:00:00", "user_id": "3"}
  235. {"index":{}}
  236. {"timestamp": "2019-01-03T13:00:00", "user_id": "1"}
  237. {"index":{}}
  238. {"timestamp": "2019-01-03T13:00:00", "user_id": "2"}
  239. {"index":{}}
  240. {"timestamp": "2019-01-03T13:00:00", "user_id": "4"}'''
  241. // Dummy bank account data used by getting-started.asciidoc
  242. buildRestTests.setups['bank'] = '''
  243. - do:
  244. indices.create:
  245. index: bank
  246. body:
  247. settings:
  248. number_of_shards: 5
  249. number_of_routing_shards: 5
  250. - do:
  251. bulk:
  252. index: bank
  253. refresh: true
  254. body: |
  255. #bank_data#
  256. '''
  257. /* Load the actual accounts only if we're going to use them. This complicates
  258. * dependency checking but that is a small price to pay for not building a
  259. * 400kb string every time we start the build. */
  260. File accountsFile = new File("$projectDir/src/test/resources/accounts.json")
  261. buildRestTests.inputs.file(accountsFile)
  262. buildRestTests.doFirst {
  263. String accounts = accountsFile.getText('UTF-8')
  264. // Indent like a yaml test needs
  265. accounts = accounts.replaceAll('(?m)^', ' ')
  266. buildRestTests.setups['bank'] =
  267. buildRestTests.setups['bank'].replace('#bank_data#', accounts)
  268. }
  269. // Used by index boost doc
  270. buildRestTests.setups['index_boost'] = '''
  271. - do:
  272. indices.create:
  273. index: index1
  274. - do:
  275. indices.create:
  276. index: index2
  277. - do:
  278. indices.put_alias:
  279. index: index1
  280. name: alias1
  281. '''
  282. // Used by sampler and diversified-sampler aggregation docs
  283. buildRestTests.setups['stackoverflow'] = '''
  284. - do:
  285. indices.create:
  286. index: stackoverflow
  287. body:
  288. settings:
  289. number_of_shards: 1
  290. number_of_replicas: 1
  291. mappings:
  292. properties:
  293. author:
  294. type: keyword
  295. tags:
  296. type: keyword
  297. - do:
  298. bulk:
  299. index: stackoverflow
  300. refresh: true
  301. body: |'''
  302. // Make Kibana strongly connected to elasticsearch and logstash
  303. // Make Kibana rarer (and therefore higher-ranking) than JavaScript
  304. // Make JavaScript strongly connected to jquery and angular
  305. // Make Cabana strongly connected to elasticsearch but only as a result of a single author
  306. for (int i = 0; i < 150; i++) {
  307. buildRestTests.setups['stackoverflow'] += """
  308. {"index":{}}
  309. {"author": "very_relevant_$i", "tags": ["elasticsearch", "kibana"]}"""
  310. }
  311. for (int i = 0; i < 50; i++) {
  312. buildRestTests.setups['stackoverflow'] += """
  313. {"index":{}}
  314. {"author": "very_relevant_$i", "tags": ["logstash", "kibana"]}"""
  315. }
  316. for (int i = 0; i < 200; i++) {
  317. buildRestTests.setups['stackoverflow'] += """
  318. {"index":{}}
  319. {"author": "partially_relevant_$i", "tags": ["javascript", "jquery"]}"""
  320. }
  321. for (int i = 0; i < 200; i++) {
  322. buildRestTests.setups['stackoverflow'] += """
  323. {"index":{}}
  324. {"author": "partially_relevant_$i", "tags": ["javascript", "angular"]}"""
  325. }
  326. for (int i = 0; i < 50; i++) {
  327. buildRestTests.setups['stackoverflow'] += """
  328. {"index":{}}
  329. {"author": "noisy author", "tags": ["elasticsearch", "cabana"]}"""
  330. }
  331. buildRestTests.setups['stackoverflow'] += """
  332. """
  333. // Used by significant_text aggregation docs
  334. buildRestTests.setups['news'] = '''
  335. - do:
  336. indices.create:
  337. index: news
  338. body:
  339. settings:
  340. number_of_shards: 1
  341. number_of_replicas: 1
  342. mappings:
  343. properties:
  344. source:
  345. type: keyword
  346. content:
  347. type: text
  348. - do:
  349. bulk:
  350. index: news
  351. refresh: true
  352. body: |'''
  353. // Make h5n1 strongly connected to bird flu
  354. for (int i = 0; i < 100; i++) {
  355. buildRestTests.setups['news'] += """
  356. {"index":{}}
  357. {"source": "very_relevant_$i", "content": "bird flu h5n1"}"""
  358. }
  359. for (int i = 0; i < 100; i++) {
  360. buildRestTests.setups['news'] += """
  361. {"index":{}}
  362. {"source": "filler_$i", "content": "bird dupFiller "}"""
  363. }
  364. for (int i = 0; i < 100; i++) {
  365. buildRestTests.setups['news'] += """
  366. {"index":{}}
  367. {"source": "filler_$i", "content": "flu dupFiller "}"""
  368. }
  369. for (int i = 0; i < 20; i++) {
  370. buildRestTests.setups['news'] += """
  371. {"index":{}}
  372. {"source": "partially_relevant_$i", "content": "elasticsearch dupFiller dupFiller dupFiller dupFiller pozmantier"}"""
  373. }
  374. for (int i = 0; i < 10; i++) {
  375. buildRestTests.setups['news'] += """
  376. {"index":{}}
  377. {"source": "partially_relevant_$i", "content": "elasticsearch logstash kibana"}"""
  378. }
  379. buildRestTests.setups['news'] += """
  380. """
  381. // Used by some aggregations
  382. buildRestTests.setups['exams'] = '''
  383. - do:
  384. indices.create:
  385. index: exams
  386. body:
  387. settings:
  388. number_of_shards: 1
  389. number_of_replicas: 1
  390. mappings:
  391. properties:
  392. grade:
  393. type: byte
  394. - do:
  395. bulk:
  396. index: exams
  397. refresh: true
  398. body: |
  399. {"index":{}}
  400. {"grade": 100, "weight": 2}
  401. {"index":{}}
  402. {"grade": 50, "weight": 3}'''
  403. buildRestTests.setups['stored_example_script'] = '''
  404. # Simple script to load a field. Not really a good example, but a simple one.
  405. - do:
  406. put_script:
  407. id: "my_script"
  408. body: { "script": { "lang": "painless", "source": "doc[params.field].value" } }
  409. - match: { acknowledged: true }
  410. '''
  411. buildRestTests.setups['stored_scripted_metric_script'] = '''
  412. - do:
  413. put_script:
  414. id: "my_init_script"
  415. body: { "script": { "lang": "painless", "source": "state.transactions = []" } }
  416. - match: { acknowledged: true }
  417. - do:
  418. put_script:
  419. id: "my_map_script"
  420. body: { "script": { "lang": "painless", "source": "state.transactions.add(doc.type.value == 'sale' ? doc.amount.value : -1 * doc.amount.value)" } }
  421. - match: { acknowledged: true }
  422. - do:
  423. put_script:
  424. id: "my_combine_script"
  425. body: { "script": { "lang": "painless", "source": "double profit = 0;for (t in state.transactions) { profit += t; } return profit" } }
  426. - match: { acknowledged: true }
  427. - do:
  428. put_script:
  429. id: "my_reduce_script"
  430. body: { "script": { "lang": "painless", "source": "double profit = 0;for (a in states) { profit += a; } return profit" } }
  431. - match: { acknowledged: true }
  432. '''
  433. // Used by analyze api
  434. buildRestTests.setups['analyze_sample'] = '''
  435. - do:
  436. indices.create:
  437. index: analyze_sample
  438. body:
  439. settings:
  440. number_of_shards: 1
  441. number_of_replicas: 0
  442. analysis:
  443. normalizer:
  444. my_normalizer:
  445. type: custom
  446. filter: [lowercase]
  447. mappings:
  448. properties:
  449. obj1.field1:
  450. type: text'''
  451. // Used by percentile/percentile-rank aggregations
  452. buildRestTests.setups['latency'] = '''
  453. - do:
  454. indices.create:
  455. index: latency
  456. body:
  457. settings:
  458. number_of_shards: 1
  459. number_of_replicas: 1
  460. mappings:
  461. properties:
  462. load_time:
  463. type: long
  464. - do:
  465. bulk:
  466. index: latency
  467. refresh: true
  468. body: |'''
  469. for (int i = 0; i < 100; i++) {
  470. def value = i
  471. if (i % 10) {
  472. value = i*10
  473. }
  474. buildRestTests.setups['latency'] += """
  475. {"index":{}}
  476. {"load_time": "$value"}"""
  477. }
  478. // Used by iprange agg
  479. buildRestTests.setups['iprange'] = '''
  480. - do:
  481. indices.create:
  482. index: ip_addresses
  483. body:
  484. settings:
  485. number_of_shards: 1
  486. number_of_replicas: 1
  487. mappings:
  488. properties:
  489. ip:
  490. type: ip
  491. - do:
  492. bulk:
  493. index: ip_addresses
  494. refresh: true
  495. body: |'''
  496. for (int i = 0; i < 255; i++) {
  497. buildRestTests.setups['iprange'] += """
  498. {"index":{}}
  499. {"ip": "10.0.0.$i"}"""
  500. }
  501. for (int i = 0; i < 5; i++) {
  502. buildRestTests.setups['iprange'] += """
  503. {"index":{}}
  504. {"ip": "9.0.0.$i"}"""
  505. buildRestTests.setups['iprange'] += """
  506. {"index":{}}
  507. {"ip": "11.0.0.$i"}"""
  508. buildRestTests.setups['iprange'] += """
  509. {"index":{}}
  510. {"ip": "12.0.0.$i"}"""
  511. }
  512. // Used by SQL because it looks SQL-ish
  513. buildRestTests.setups['library'] = '''
  514. - do:
  515. indices.create:
  516. include_type_name: true
  517. index: library
  518. body:
  519. settings:
  520. number_of_shards: 1
  521. number_of_replicas: 1
  522. mappings:
  523. book:
  524. properties:
  525. name:
  526. type: text
  527. fields:
  528. keyword:
  529. type: keyword
  530. author:
  531. type: text
  532. fields:
  533. keyword:
  534. type: keyword
  535. release_date:
  536. type: date
  537. page_count:
  538. type: short
  539. - do:
  540. bulk:
  541. index: library
  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. refresh: true
  884. body: |
  885. {"index": {"_id":"1"}}
  886. {"airline":"JZA","responsetime":990.4628,"time":"2016-02-07T00:00:00+0000", "doc_count": 5}
  887. {"index": {"_id":"2"}}
  888. {"airline":"JBU","responsetime":877.5927,"time":"2016-02-07T00:00:00+0000", "doc_count": 23}
  889. {"index": {"_id":"3"}}
  890. {"airline":"KLM","responsetime":1355.4812,"time":"2016-02-07T00:00:00+0000", "doc_count": 42}
  891. '''
  892. buildRestTests.setups['farequote_job'] = buildRestTests.setups['farequote_data'] + '''
  893. - do:
  894. ml.put_job:
  895. job_id: "farequote"
  896. body: >
  897. {
  898. "analysis_config": {
  899. "bucket_span": "60m",
  900. "detectors": [{
  901. "function": "mean",
  902. "field_name": "responsetime",
  903. "by_field_name": "airline"
  904. }],
  905. "summary_count_field_name": "doc_count"
  906. },
  907. "data_description": {
  908. "time_field": "time"
  909. }
  910. }
  911. '''
  912. buildRestTests.setups['farequote_datafeed'] = buildRestTests.setups['farequote_job'] + '''
  913. - do:
  914. ml.put_datafeed:
  915. datafeed_id: "datafeed-farequote"
  916. body: >
  917. {
  918. "job_id":"farequote",
  919. "indexes":"farequote"
  920. }
  921. '''
  922. buildRestTests.setups['server_metrics_index'] = '''
  923. - do:
  924. indices.create:
  925. index: server-metrics
  926. body:
  927. settings:
  928. number_of_shards: 1
  929. number_of_replicas: 0
  930. mappings:
  931. metric:
  932. properties:
  933. timestamp:
  934. type: date
  935. total:
  936. type: long
  937. '''
  938. buildRestTests.setups['server_metrics_data'] = buildRestTests.setups['server_metrics_index'] + '''
  939. - do:
  940. bulk:
  941. index: server-metrics
  942. refresh: true
  943. body: |
  944. {"index": {"_id":"1177"}}
  945. {"timestamp":"2017-03-23T13:00:00","total":40476}
  946. {"index": {"_id":"1178"}}
  947. {"timestamp":"2017-03-23T13:00:00","total":15287}
  948. {"index": {"_id":"1179"}}
  949. {"timestamp":"2017-03-23T13:00:00","total":-776}
  950. {"index": {"_id":"1180"}}
  951. {"timestamp":"2017-03-23T13:00:00","total":11366}
  952. {"index": {"_id":"1181"}}
  953. {"timestamp":"2017-03-23T13:00:00","total":3606}
  954. {"index": {"_id":"1182"}}
  955. {"timestamp":"2017-03-23T13:00:00","total":19006}
  956. {"index": {"_id":"1183"}}
  957. {"timestamp":"2017-03-23T13:00:00","total":38613}
  958. {"index": {"_id":"1184"}}
  959. {"timestamp":"2017-03-23T13:00:00","total":19516}
  960. {"index": {"_id":"1185"}}
  961. {"timestamp":"2017-03-23T13:00:00","total":-258}
  962. {"index": {"_id":"1186"}}
  963. {"timestamp":"2017-03-23T13:00:00","total":9551}
  964. {"index": {"_id":"1187"}}
  965. {"timestamp":"2017-03-23T13:00:00","total":11217}
  966. {"index": {"_id":"1188"}}
  967. {"timestamp":"2017-03-23T13:00:00","total":22557}
  968. {"index": {"_id":"1189"}}
  969. {"timestamp":"2017-03-23T13:00:00","total":40508}
  970. {"index": {"_id":"1190"}}
  971. {"timestamp":"2017-03-23T13:00:00","total":11887}
  972. {"index": {"_id":"1191"}}
  973. {"timestamp":"2017-03-23T13:00:00","total":31659}
  974. '''
  975. buildRestTests.setups['server_metrics_job'] = buildRestTests.setups['server_metrics_data'] + '''
  976. - do:
  977. ml.put_job:
  978. job_id: "total-requests"
  979. body: >
  980. {
  981. "description" : "Total sum of requests",
  982. "analysis_config" : {
  983. "bucket_span":"10m",
  984. "detectors" :[
  985. {
  986. "detector_description": "Sum of total",
  987. "function": "sum",
  988. "field_name": "total"
  989. }
  990. ]},
  991. "data_description" : {
  992. "time_field":"timestamp",
  993. "time_format": "epoch_ms"
  994. }
  995. }
  996. '''
  997. buildRestTests.setups['server_metrics_datafeed'] = buildRestTests.setups['server_metrics_job'] + '''
  998. - do:
  999. ml.put_datafeed:
  1000. datafeed_id: "datafeed-total-requests"
  1001. body: >
  1002. {
  1003. "job_id":"total-requests",
  1004. "indexes":"server-metrics"
  1005. }
  1006. '''
  1007. buildRestTests.setups['server_metrics_openjob'] = buildRestTests.setups['server_metrics_datafeed'] + '''
  1008. - do:
  1009. ml.open_job:
  1010. job_id: "total-requests"
  1011. '''
  1012. buildRestTests.setups['server_metrics_startdf'] = buildRestTests.setups['server_metrics_openjob'] + '''
  1013. - do:
  1014. ml.start_datafeed:
  1015. datafeed_id: "datafeed-total-requests"
  1016. '''
  1017. buildRestTests.setups['calendar_outages'] = '''
  1018. - do:
  1019. ml.put_calendar:
  1020. calendar_id: "planned-outages"
  1021. '''
  1022. buildRestTests.setups['calendar_outages_addevent'] = buildRestTests.setups['calendar_outages'] + '''
  1023. - do:
  1024. ml.post_calendar_events:
  1025. calendar_id: "planned-outages"
  1026. body: >
  1027. { "description": "event 1", "start_time": "2017-12-01T00:00:00Z", "end_time": "2017-12-02T00:00:00Z", "calendar_id": "planned-outages" }
  1028. '''
  1029. buildRestTests.setups['calendar_outages_openjob'] = buildRestTests.setups['server_metrics_openjob'] + '''
  1030. - do:
  1031. ml.put_calendar:
  1032. calendar_id: "planned-outages"
  1033. '''
  1034. buildRestTests.setups['calendar_outages_addjob'] = buildRestTests.setups['server_metrics_openjob'] + '''
  1035. - do:
  1036. ml.put_calendar:
  1037. calendar_id: "planned-outages"
  1038. body: >
  1039. {
  1040. "job_ids": ["total-requests"]
  1041. }
  1042. '''
  1043. buildRestTests.setups['calendar_outages_addevent'] = buildRestTests.setups['calendar_outages_addjob'] + '''
  1044. - do:
  1045. ml.post_calendar_events:
  1046. calendar_id: "planned-outages"
  1047. body: >
  1048. { "events" : [
  1049. { "description": "event 1", "start_time": "1513641600000", "end_time": "1513728000000"},
  1050. { "description": "event 2", "start_time": "1513814400000", "end_time": "1513900800000"},
  1051. { "description": "event 3", "start_time": "1514160000000", "end_time": "1514246400000"}
  1052. ]}
  1053. '''
  1054. // used by median absolute deviation aggregation
  1055. buildRestTests.setups['reviews'] = '''
  1056. - do:
  1057. indices.create:
  1058. index: reviews
  1059. body:
  1060. settings:
  1061. number_of_shards: 1
  1062. number_of_replicas: 0
  1063. mappings:
  1064. properties:
  1065. product:
  1066. type: keyword
  1067. rating:
  1068. type: long
  1069. - do:
  1070. bulk:
  1071. index: reviews
  1072. refresh: true
  1073. body: |
  1074. {"index": {"_id": "1"}}
  1075. {"product": "widget-foo", "rating": 1}
  1076. {"index": {"_id": "2"}}
  1077. {"product": "widget-foo", "rating": 5}
  1078. '''
  1079. buildRestTests.setups['remote_cluster'] = buildRestTests.setups['host'] + '''
  1080. - do:
  1081. cluster.put_settings:
  1082. body:
  1083. persistent:
  1084. cluster.remote.remote_cluster.seeds: $transport_host
  1085. '''
  1086. buildRestTests.setups['remote_cluster_and_leader_index'] = buildRestTests.setups['remote_cluster'] + '''
  1087. - do:
  1088. indices.create:
  1089. index: leader_index
  1090. body:
  1091. settings:
  1092. index.number_of_replicas: 0
  1093. index.number_of_shards: 1
  1094. index.soft_deletes.enabled: true
  1095. '''
  1096. buildRestTests.setups['seats'] = '''
  1097. - do:
  1098. indices.create:
  1099. index: seats
  1100. body:
  1101. settings:
  1102. number_of_shards: 1
  1103. number_of_replicas: 0
  1104. mappings:
  1105. properties:
  1106. theatre:
  1107. type: keyword
  1108. cost:
  1109. type: long
  1110. row:
  1111. type: long
  1112. number:
  1113. type: long
  1114. sold:
  1115. type: boolean
  1116. - do:
  1117. bulk:
  1118. index: seats
  1119. refresh: true
  1120. body: |
  1121. {"index":{"_id": "1"}}
  1122. {"theatre": "Skyline", "cost": 37, "row": 1, "number": 7, "sold": false}
  1123. {"index":{"_id": "2"}}
  1124. {"theatre": "Graye", "cost": 30, "row": 3, "number": 5, "sold": false}
  1125. {"index":{"_id": "3"}}
  1126. {"theatre": "Graye", "cost": 33, "row": 2, "number": 6, "sold": false}
  1127. {"index":{"_id": "4"}}
  1128. {"theatre": "Skyline", "cost": 20, "row": 5, "number": 2, "sold": false}'''
  1129. buildRestTests.setups['kibana_sample_data_ecommerce'] = '''
  1130. - do:
  1131. indices.create:
  1132. index: kibana_sample_data_ecommerce
  1133. body:
  1134. settings:
  1135. number_of_shards: 1
  1136. number_of_replicas: 0
  1137. '''
  1138. buildRestTests.setups['simple_kibana_continuous_pivot'] = buildRestTests.setups['kibana_sample_data_ecommerce'] + '''
  1139. - do:
  1140. raw:
  1141. method: PUT
  1142. path: _transform/simple-kibana-ecomm-pivot
  1143. body: >
  1144. {
  1145. "source": {
  1146. "index": "kibana_sample_data_ecommerce",
  1147. "query": {
  1148. "term": {
  1149. "geoip.continent_name": {
  1150. "value": "Asia"
  1151. }
  1152. }
  1153. }
  1154. },
  1155. "pivot": {
  1156. "group_by": {
  1157. "customer_id": {
  1158. "terms": {
  1159. "field": "customer_id"
  1160. }
  1161. }
  1162. },
  1163. "aggregations": {
  1164. "max_price": {
  1165. "max": {
  1166. "field": "taxful_total_price"
  1167. }
  1168. }
  1169. }
  1170. },
  1171. "description": "Maximum priced ecommerce data",
  1172. "dest": {
  1173. "index": "kibana_sample_data_ecommerce_transform",
  1174. "pipeline": "add_timestamp_pipeline"
  1175. },
  1176. "frequency": "5m",
  1177. "sync": {
  1178. "time": {
  1179. "field": "order_date",
  1180. "delay": "60s"
  1181. }
  1182. }
  1183. }
  1184. '''
  1185. buildRestTests.setups['setup_logdata'] = '''
  1186. - do:
  1187. indices.create:
  1188. index: logdata
  1189. body:
  1190. settings:
  1191. number_of_shards: 1
  1192. number_of_replicas: 1
  1193. mappings:
  1194. properties:
  1195. grade:
  1196. type: byte
  1197. - do:
  1198. bulk:
  1199. index: logdata
  1200. refresh: true
  1201. body: |
  1202. {"index":{}}
  1203. {"grade": 100, "weight": 2}
  1204. {"index":{}}
  1205. {"grade": 50, "weight": 3}
  1206. '''
  1207. buildRestTests.setups['logdata_job'] = buildRestTests.setups['setup_logdata'] + '''
  1208. - do:
  1209. ml.put_data_frame_analytics:
  1210. id: "loganalytics"
  1211. body: >
  1212. {
  1213. "source": {
  1214. "index": "logdata"
  1215. },
  1216. "dest": {
  1217. "index": "logdata_out"
  1218. },
  1219. "analysis": {
  1220. "outlier_detection": {}
  1221. }
  1222. }
  1223. '''
  1224. // Used by snapshot lifecycle management docs
  1225. buildRestTests.setups['setup-repository'] = '''
  1226. - do:
  1227. snapshot.create_repository:
  1228. repository: my_repository
  1229. body:
  1230. type: fs
  1231. settings:
  1232. location: buildDir/cluster/shared/repo
  1233. '''