Advertisement
Guest User

elasticsearch_BoolIntersect

a guest
Jan 14th, 2016
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.25 KB | None | 0 0
  1. curl -XPUT 'http://localhost:9200/test_attribs?pretty' -d '{
  2. "settings": {
  3. "analysis": {
  4. "analyzer": {
  5. "ngram_analyzer": {
  6. "filter": [
  7. "lowercase",
  8. "asciifolding",
  9. "ngram_filter"
  10. ],
  11. "tokenizer": "whitespace",
  12. "type": "custom"
  13. },
  14. "searchterm_analyzer": {
  15. "filter": [
  16. "lowercase",
  17. "asciifolding"
  18. ],
  19. "tokenizer": "whitespace",
  20. "type": "custom"
  21. }
  22. },
  23. "filter": {
  24. "ngram_filter": {
  25. "max_gram": 30,
  26. "min_gram": 3,
  27. "token_chars": [
  28. "letter",
  29. "digit",
  30. "punctuation",
  31. "symbol"
  32. ],
  33. "type": "edgeNGram"
  34. }
  35. }
  36. },
  37. "number_of_replicas": 0,
  38. "number_of_shards": 5
  39. }
  40. }'
  41.  
  42. curl -XPUT 'http://localhost:9200/test_attribs/_mapping/prodgroup_with_attribs?pretty' -d '{
  43. "prodgroup_with_attribs": {
  44. "dynamic": "strict",
  45. "properties": {
  46. "attributes": {
  47. "properties": {
  48. "key": {
  49. "index": "not_analyzed",
  50. "type": "string"
  51. },
  52. "value": {
  53. "index": "not_analyzed",
  54. "type": "string"
  55. }
  56. },
  57. "type": "nested"
  58. },
  59. "prodno": {
  60. "index_analyzer": "ngram_analyzer",
  61. "search_analyzer": "searchterm_analyzer",
  62. "type": "string"
  63. }
  64. }
  65. }
  66. }'
  67.  
  68.  
  69. curl -XPUT 'http://localhost:9200/test_attribs/prodgroup_with_attribs/WEBC2590?pretty' -d '{
  70. "attributes": [
  71. {
  72. "key": "Color",
  73. "value": [
  74. "Black",
  75. "Blue",
  76. "Teal"
  77. ]
  78. },
  79. {
  80. "key": "Type",
  81. "value": [
  82. "Autoclavable"
  83. ]
  84. },
  85. {
  86. "key": "Amount of Holes",
  87. "value": [
  88. "10",
  89. "15",
  90. "27"
  91. ]
  92. },
  93. {
  94. "key": "Hole Configuration",
  95. "value": [
  96. "FG",
  97. "FG/Latch",
  98. "Latch"
  99. ]
  100. },
  101. {
  102. "key": "Manufacturer",
  103. "value": "Kerr Rotary"
  104. },
  105. {
  106. "key": "Subcategory",
  107. "value": "Bur Blocks"
  108. }
  109. ],
  110. "prodno": [
  111. "9590062",
  112. "9590066",
  113. "9590070",
  114. "9590064",
  115. "9590078",
  116. "9590082",
  117. "9590050"
  118. ]
  119. }'
  120.  
  121. curl -XPUT 'http://localhost:9200/test_attribs/prodgroup_with_attribs/WEBC2590?pretty' -d '{
  122. "attributes": [
  123. {
  124. "key": "Color",
  125. "value": [
  126. "Black",
  127. "Blue",
  128. "Teal"
  129. ]
  130. },
  131. {
  132. "key": "Type",
  133. "value": [
  134. "Autoclavable"
  135. ]
  136. },
  137. {
  138. "key": "Amount of Holes",
  139. "value": [
  140. "10",
  141. "15",
  142. "27"
  143. ]
  144. },
  145. {
  146. "key": "Hole Configuration",
  147. "value": [
  148. "FG",
  149. "FG/Latch",
  150. "Latch"
  151. ]
  152. },
  153. {
  154. "key": "Manufacturer",
  155. "value": "Kerr Rotary"
  156. },
  157. {
  158. "key": "Subcategory",
  159. "value": "Bur Blocks"
  160. }
  161. ],
  162. "prodno": [
  163. "9593718"
  164. ]
  165. }'
  166.  
  167. curl -XPUT 'http://localhost:9200/test_attribs/prodgroup_with_attribs/WEBC2590?pretty' -d '{
  168. "attributes": [
  169. {
  170. "key": "Color",
  171. "value": [
  172. "Black",
  173. "Blue",
  174. "Teal"
  175. ]
  176. },
  177. {
  178. "key": "Type",
  179. "value": [
  180. "Autoclavable"
  181. ]
  182. },
  183. {
  184. "key": "Amount of Holes",
  185. "value": [
  186. "10",
  187. "15",
  188. "27"
  189. ]
  190. },
  191. {
  192. "key": "Hole Configuration",
  193. "value": [
  194. "FG",
  195. "FG/Latch",
  196. "Latch"
  197. ]
  198. },
  199. {
  200. "key": "Manufacturer",
  201. "value": "Kerr Rotary"
  202. },
  203. {
  204. "key": "Subcategory",
  205. "value": "Bur Blocks"
  206. }
  207. ],
  208. "prodno": [
  209. "8901086"
  210. ]
  211. }'
  212.  
  213. curl -XPUT 'http://localhost:9200/test_attribs/prodgroup_with_attribs/WEBC2590?pretty' -d '{
  214. "attributes": [
  215. {
  216. "key": "Color",
  217. "value": [
  218. "Black",
  219. "Blue",
  220. "Teal"
  221. ]
  222. },
  223. {
  224. "key": "Type",
  225. "value": [
  226. "Autoclavable"
  227. ]
  228. },
  229. {
  230. "key": "Amount of Holes",
  231. "value": [
  232. "10",
  233. "15",
  234. "27"
  235. ]
  236. },
  237. {
  238. "key": "Hole Configuration",
  239. "value": [
  240. "FG",
  241. "FG/Latch",
  242. "Latch"
  243. ]
  244. },
  245. {
  246. "key": "Manufacturer",
  247. "value": "Kerr Rotary"
  248. },
  249. {
  250. "key": "Subcategory",
  251. "value": "Bur Blocks"
  252. }
  253. ],
  254. "prodno": [
  255. "8901090"
  256. ]
  257. }'
  258.  
  259.  
  260.  
  261.  
  262.  
  263. curl -XGET 'http://localhost:9200/prodgroups_with_attribs/prodgroup_with_attribs/_search?pretty' -d '{
  264. "query": {
  265. "filtered": {
  266. "filter": {
  267. "nested": {
  268. "filter": {
  269. "bool": {
  270. "must": [
  271. {
  272. "bool": {
  273. "must": [
  274. {
  275. "term": {
  276. "attributes.key": "Color"
  277. }
  278. },
  279. {
  280. "terms": {
  281. "attributes.value": [
  282. "Blue"
  283. ]
  284. }
  285. }
  286. ]
  287. }
  288. }
  289. ]
  290. }
  291. },
  292. "path": "attributes"
  293. }
  294. },
  295. "query": {
  296. "multi_match": {
  297. "fields": [
  298. "_all"
  299. ],
  300. "query": "bur"
  301. }
  302. }
  303. }
  304. },
  305. "size": 20
  306. }'
  307.  
  308.  
  309. curl -XGET 'http://localhost:9200/prodgroups_with_attribs/prodgroup_with_attribs/_search?pretty' -d '{
  310. "query": {
  311. "filtered": {
  312. "filter": {
  313. "nested": {
  314. "filter": {
  315. "bool": {
  316. "must": [
  317. {
  318. "bool": {
  319. "must": [
  320. {
  321. "term": {
  322. "attributes.key": "Type"
  323. }
  324. },
  325. {
  326. "terms": {
  327. "attributes.value": [
  328. "Autoclavable"
  329. ]
  330. }
  331. }
  332. ]
  333. }
  334. }
  335. ]
  336. }
  337. },
  338. "path": "attributes"
  339. }
  340. },
  341. "query": {
  342. "multi_match": {
  343. "fields": [
  344. "_all"
  345. ],
  346. "query": "bur"
  347. }
  348. }
  349. }
  350. },
  351. "size": 20
  352. }'
  353.  
  354.  
  355.  
  356. curl -XGET 'http://localhost:9200/prodgroups_with_attribs/prodgroup_with_attribs/_search?pretty' -d '{
  357. "query": {
  358. "filtered": {
  359. "filter": {
  360. "nested": {
  361. "filter": {
  362. "bool": {
  363. "must": [
  364. {
  365. "bool": {
  366. "must": [
  367. {
  368. "term": {
  369. "attributes.key": "Color"
  370. }
  371. },
  372. {
  373. "terms": {
  374. "attributes.value": [
  375. "Blue"
  376. ]
  377. }
  378. }
  379. ]
  380. }
  381. },
  382. {
  383. "bool": {
  384. "must": [
  385. {
  386. "term": {
  387. "attributes.key": "Type"
  388. }
  389. },
  390. {
  391. "terms": {
  392. "attributes.value": [
  393. "Autoclavable"
  394. ]
  395. }
  396. }
  397. ]
  398. }
  399. }
  400. ]
  401. }
  402. },
  403. "path": "attributes"
  404. }
  405. },
  406. "query": {
  407. "multi_match": {
  408. "fields": [
  409. "_all"
  410. ],
  411. "query": "bur"
  412. }
  413. }
  414. }
  415. },
  416. "size": 20
  417. }'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement