build.gradle 46 KB

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