Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- POST users/user
- {
- "name" :"SMITH",
- "emails" : [
- "smith@gmail.com"
- ]
- }
- POST users/user
- {
- "name" :"SMITH",
- "emails" : [
- "mrsmith@gmail.com",
- "smith@gmail.com"
- ]
- }
- POST users/_search
- {
- "size": 0,
- "aggs": {
- "duplicateCount": {
- "terms": {
- "script": {
- "inline": "doc['emails.keyword'].value + '_' + doc['name.keyword'].value"
- }
- }
- }
- }
- }
- "aggregations": {
- "duplicateCount": {
- "doc_count_error_upper_bound": 0,
- "sum_other_doc_count": 0,
- "buckets": [
- {
- "key": "mrsmith@gmail.com_SMITH",
- "doc_count": 1
- },
- {
- "key": "smith@gmail.com_SMITH",
- "doc_count": 1
- }
- ]
- }
- }
- {
- "from" : 0,
- "size" : 0,
- "_source" : true,
- "query" : {
- "bool" : {
- "must" : [ {
- "match" : {
- "name" : {
- "query" : "SMITH",
- "operator" : "OR",
- "fuzziness" : "AUTO",
- "prefix_length" : 1,
- "max_expansions" : 50,
- "fuzzy_transpositions" : true,
- "lenient" : false,
- "zero_terms_query" : "NONE",
- "boost" : 1
- }
- }
- } ]
- }
- },
- "aggs": {
- "duplicateCount": {
- "terms": {
- "script": {
- "inline": "doc['emails.keyword'].value + '_' + doc['name.keyword'].value"
- }
- }
- },
- "duplicateCount2": {
- "terms": {
- "field": "emails.keyword"
- }
- }
- }
- }
- {
- "took" : 53,
- "timed_out" : false,
- "_shards" : {
- "total" : 3,
- "successful" : 3,
- "failed" : 0
- },
- "hits" : {
- "total" : 2,
- "max_score" : 0.0,
- "hits" : [ ]
- },
- "aggregations" : {
- "duplicateCount2" : {
- "doc_count_error_upper_bound" : 0,
- "sum_other_doc_count" : 0,
- "buckets" : [ {
- "key" : "smith@gmail.com",
- "doc_count" : 2
- }, {
- "key" : "mrsmith@gmail.com",
- "doc_count" : 1
- } ]
- },
- "duplicateCount" : {
- "doc_count_error_upper_bound" : 0,
- "sum_other_doc_count" : 0,
- "buckets" : [ {
- "key" : "mrsmith@gmail.com_SMITH",
- "doc_count" : 1
- }, {
- "key" : "smith@gmail.com_SMITH",
- "doc_count" : 1
- } ]
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement