# Return Duplicates

**URL:** <https://discuss.elastic.co/t/return-duplicates/97016>\
**Category:** Elasticsearch\
**Created:** [August 14, 2017, 7:34pm UTC](https://discuss.elastic.co/t/return-duplicates/97016 "2017-08-14T19:34:26Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![The\_Juke\_Box\_Hero](https://avatars.discourse-cdn.com/v4/letter/t/9de053/32.png) [@The\_Juke\_Box\_Hero](https://discuss.elastic.co/u/The_Juke_Box_Hero)\
**Post date:** [August 14, 2017, 7:34pm UTC](https://discuss.elastic.co/t/return-duplicates/97016/1 "2017-08-14T19:34:26Z")

</div>

Hi, I researched the web and the forums for this especific use case but could not find relevant information.

Goal:

From my interface, I want to pass a date range and state code to my elastic instance to find all documents that contain similar terms.

Example:  
{ID: 1, Case:1234, State:CA}{ID:7, Case:CA-1234, State:CA}

I've done something similar using a SQL query but is not efficent, I thought about doing it using Logstash but I'm requiered to show the duplicate result before deciding which document to save into a clean index.

Any advise will be much appreciated.

Regards

---

<div class="post-metadata">

**Author:** ![talevy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/talevy/32/44896_2.png) [@talevy](https://discuss.elastic.co/u/talevy)\
**Post date:** [August 14, 2017, 9:16pm UTC](https://discuss.elastic.co/t/return-duplicates/97016/2 "2017-08-14T21:16:00Z")

</div>

What do you mean by "similar", is this not the same as running a query for documents that match a specific date range and have a specific `State` value?

---

<div class="post-metadata">

**Author:** ![The\_Juke\_Box\_Hero](https://avatars.discourse-cdn.com/v4/letter/t/9de053/32.png) [@The\_Juke\_Box\_Hero](https://discuss.elastic.co/u/The_Juke_Box_Hero)\
**Post date:** [August 14, 2017, 9:19pm UTC](https://discuss.elastic.co/t/return-duplicates/97016/3 "2017-08-14T21:19:04Z")

</div>

Not "State" per say, but rather the "Case" mapping for example where I could have a document with 1234 and another one with CA-1234, the search should return both 1234 and CA-1234 as similar documents. Hope this makes sense.

UPDATE:

To make it clear

- User enters date rage and selects state, clicks button to search for similar documents in CA
- ES finds that CA-1234 and 1234 might be similar and returns both

I understand that my query has to have the mappings I want to run a search for, but in the current context I don't want the user to have to input the actual value we are looking for but rather have it submit a time frame to look for similar documents in that range, by comparing field that are suppost to be unique but that might contain variations thus creating a duplicate record with slight variations.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [September 11, 2017, 9:19pm UTC](https://discuss.elastic.co/t/return-duplicates/97016/4 "2017-09-11T21:19:06Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
