build.gradle 46 KB

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