Advertisement
Guest User

Untitled

a guest
Sep 1st, 2017
675
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.22 KB | None | 0 0
  1. POST users/user
  2. {
  3. "name" :"SMITH",
  4. "emails" : [
  5. "smith@gmail.com"
  6. ]
  7. }
  8.  
  9. POST users/user
  10. {
  11. "name" :"SMITH",
  12. "emails" : [
  13. "mrsmith@gmail.com",
  14. "smith@gmail.com"
  15. ]
  16. }
  17.  
  18. POST users/_search
  19. {
  20. "size": 0,
  21. "aggs": {
  22. "duplicateCount": {
  23. "terms": {
  24. "script": {
  25. "inline": "doc['emails.keyword'].value + '_' + doc['name.keyword'].value"
  26. }
  27. }
  28. }
  29. }
  30. }
  31.  
  32. "aggregations": {
  33. "duplicateCount": {
  34. "doc_count_error_upper_bound": 0,
  35. "sum_other_doc_count": 0,
  36. "buckets": [
  37. {
  38. "key": "mrsmith@gmail.com_SMITH",
  39. "doc_count": 1
  40. },
  41. {
  42. "key": "smith@gmail.com_SMITH",
  43. "doc_count": 1
  44. }
  45. ]
  46. }
  47. }
  48.  
  49. {
  50. "from" : 0,
  51. "size" : 0,
  52. "_source" : true,
  53. "query" : {
  54. "bool" : {
  55. "must" : [ {
  56. "match" : {
  57. "name" : {
  58. "query" : "SMITH",
  59. "operator" : "OR",
  60. "fuzziness" : "AUTO",
  61. "prefix_length" : 1,
  62. "max_expansions" : 50,
  63. "fuzzy_transpositions" : true,
  64. "lenient" : false,
  65. "zero_terms_query" : "NONE",
  66. "boost" : 1
  67. }
  68. }
  69. } ]
  70. }
  71. },
  72. "aggs": {
  73. "duplicateCount": {
  74. "terms": {
  75. "script": {
  76. "inline": "doc['emails.keyword'].value + '_' + doc['name.keyword'].value"
  77. }
  78. }
  79. },
  80. "duplicateCount2": {
  81. "terms": {
  82. "field": "emails.keyword"
  83. }
  84. }
  85. }
  86. }
  87.  
  88. {
  89. "took" : 53,
  90. "timed_out" : false,
  91. "_shards" : {
  92. "total" : 3,
  93. "successful" : 3,
  94. "failed" : 0
  95. },
  96. "hits" : {
  97. "total" : 2,
  98. "max_score" : 0.0,
  99. "hits" : [ ]
  100. },
  101. "aggregations" : {
  102. "duplicateCount2" : {
  103. "doc_count_error_upper_bound" : 0,
  104. "sum_other_doc_count" : 0,
  105. "buckets" : [ {
  106. "key" : "smith@gmail.com",
  107. "doc_count" : 2
  108. }, {
  109. "key" : "mrsmith@gmail.com",
  110. "doc_count" : 1
  111. } ]
  112. },
  113. "duplicateCount" : {
  114. "doc_count_error_upper_bound" : 0,
  115. "sum_other_doc_count" : 0,
  116. "buckets" : [ {
  117. "key" : "mrsmith@gmail.com_SMITH",
  118. "doc_count" : 1
  119. }, {
  120. "key" : "smith@gmail.com_SMITH",
  121. "doc_count" : 1
  122. } ]
  123. }
  124. }
  125. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement