Advertisement
Guest User

boolNestedFilterBehavior

a guest
Jan 15th, 2016
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.78 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_test?pretty' -d '{
  43. "prodgroup_with_attribs_test": {
  44. "dynamic": "strict",
  45. "properties": {
  46. "Color": {
  47. "index": "not_analyzed",
  48. "search_analyzer": "searchterm_analyzer",
  49. "type": "string"
  50. },
  51. "attributes": {
  52. "properties": {
  53. "key": {
  54. "index": "not_analyzed",
  55. "type": "string"
  56. },
  57. "value": {
  58. "index": "not_analyzed",
  59. "type": "string"
  60. }
  61. },
  62. "type": "nested"
  63. },
  64. "prodno": {
  65. "index_analyzer": "ngram_analyzer",
  66. "search_analyzer": "searchterm_analyzer",
  67. "type": "string"
  68. },
  69. "zoom": {
  70. "index": "not_analyzed",
  71. "search_analyzer": "searchterm_analyzer",
  72. "type": "string"
  73. }
  74. }
  75. }
  76. }'
  77.  
  78. curl -XPUT 'http://localhost:9200/test_attribs/prodgroup_with_attribs_test/WEBC2590?pretty' -d '{
  79. "Color": [
  80. "Blue"
  81. ],
  82. "attributes": [
  83. {
  84. "key": "Color",
  85. "value": [
  86. "Black",
  87. "Blue",
  88. "Teal"
  89. ]
  90. },
  91. {
  92. "key": "Type",
  93. "value": [
  94. "Autoclavable"
  95. ]
  96. },
  97. {
  98. "key": "Amount of Holes",
  99. "value": [
  100. "10",
  101. "15",
  102. "27"
  103. ]
  104. },
  105. {
  106. "key": "Hole Configuration",
  107. "value": [
  108. "FG",
  109. "FG/Latch",
  110. "Latch"
  111. ]
  112. }
  113. ],
  114. "prodno": [
  115. "9590062",
  116. "9590066",
  117. "9590070",
  118. "9590064",
  119. "9590078",
  120. "9590082",
  121. "9590050"
  122. ],
  123. "zoom": [
  124. "autoclavable"
  125. ]
  126. }'
  127.  
  128.  
  129.  
  130. curl -XGET 'http://localhost:9200/test_attribs/prodgroup_with_attribs_test/_search?pretty' -d '{
  131. "query": {
  132. "filtered": {
  133. "filter": {
  134. "nested": {
  135. "filter": {
  136. "bool": {
  137. "must": [
  138. {
  139. "bool": {
  140. "must": [
  141. {
  142. "term": {
  143. "attributes.key": "Color"
  144. }
  145. },
  146. {
  147. "terms": {
  148. "attributes.value": [
  149. "Blue"
  150. ]
  151. }
  152. }
  153. ]
  154. }
  155. }
  156. ]
  157. }
  158. },
  159. "path": "attributes"
  160. }
  161. }
  162. }
  163. },
  164. "size": 20
  165. }'
  166.  
  167.  
  168. curl -XGET 'http://localhost:9200/test_attribs/prodgroup_with_attribs_test/_search?pretty' -d '{
  169. "query": {
  170. "filtered": {
  171. "filter": {
  172. "nested": {
  173. "filter": {
  174. "bool": {
  175. "must": [
  176. {
  177. "bool": {
  178. "must": [
  179. {
  180. "term": {
  181. "attributes.key": "Type"
  182. }
  183. },
  184. {
  185. "terms": {
  186. "attributes.value": [
  187. "Autoclavable"
  188. ]
  189. }
  190. }
  191. ]
  192. }
  193. }
  194. ]
  195. }
  196. },
  197. "path": "attributes"
  198. }
  199. }
  200. }
  201. },
  202. "size": 20
  203. }'
  204.  
  205.  
  206. curl -XGET 'http://localhost:9200/test_attribs/prodgroup_with_attribs_test/_search?pretty' -d '{
  207. "query": {
  208. "filtered": {
  209. "filter": {
  210. "nested": {
  211. "filter": {
  212. "bool": {
  213. "must": [
  214. {
  215. "bool": {
  216. "must": [
  217. {
  218. "term": {
  219. "attributes.key": "Color"
  220. }
  221. },
  222. {
  223. "terms": {
  224. "attributes.value": [
  225. "Blue"
  226. ]
  227. }
  228. }
  229. ]
  230. }
  231. },
  232. {
  233. "bool": {
  234. "must": [
  235. {
  236. "term": {
  237. "attributes.key": "Type"
  238. }
  239. },
  240. {
  241. "terms": {
  242. "attributes.value": [
  243. "Autoclavable"
  244. ]
  245. }
  246. }
  247. ]
  248. }
  249. }
  250. ]
  251. }
  252. },
  253. "path": "attributes"
  254. }
  255. }
  256. }
  257. },
  258. "size": 20
  259. }'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement