# Making a field unique

**URL:** <https://discuss.elastic.co/t/making-a-field-unique/6692>\
**Category:** Elasticsearch\
**Created:** [February 13, 2012, 7:08pm UTC](https://discuss.elastic.co/t/making-a-field-unique/6692 "2012-02-13T19:08:37Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Frank\_LaRosa](https://avatars.discourse-cdn.com/v4/letter/f/bc8723/32.png) [@Frank\_LaRosa](https://discuss.elastic.co/u/Frank_LaRosa)\
**Post date:** [February 13, 2012, 7:08pm UTC](https://discuss.elastic.co/t/making-a-field-unique/6692/1 "2012-02-13T19:08:37Z")

</div>

Hi,

Is it possible to make a field unique? I'm using the Java syntax, so  
my mapping definition looks like this:

.startObject("idea\_signature")  
.field("type", "string")  
.field("store", "yes")  
.field("index", "not\_analyzed")  
.endObject()

What do I need to do in order to make sure that this field is treated  
as a unique identifier? Thanks.

---

<div class="post-metadata">

**Author:** ![Frank\_LaRosa](https://avatars.discourse-cdn.com/v4/letter/f/bc8723/32.png) [@Frank\_LaRosa](https://discuss.elastic.co/u/Frank_LaRosa)\
**Post date:** [February 13, 2012, 7:28pm UTC](https://discuss.elastic.co/t/making-a-field-unique/6692/2 "2012-02-13T19:28:50Z")

</div>

Is this the solution?

.startObject("idea\_signature")  
.field("type", "string")  
.field("store", "yes")  
.field("index", "not\_analyzed")  
.endObject()

.startObject("\_id")  
.field("path", "idea\_signature")  
.endObject()

On Feb 13, 1:08 pm, Frank LaRosa [fr...@studyblue.com](mailto:fr...@studyblue.com) wrote:

> Hi,
> 
> Is it possible to make a field unique? I'm using the Java syntax, so  
> my mapping definition looks like this:
> 
> .startObject("idea\_signature")  
> .field("type", "string")  
> .field("store", "yes")  
> .field("index", "not\_analyzed")  
> .endObject()
> 
> What do I need to do in order to make sure that this field is treated  
> as a unique identifier? Thanks.

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [February 14, 2012, 2:14pm UTC](https://discuss.elastic.co/t/making-a-field-unique/6692/3 "2012-02-14T14:14:21Z")

</div>

What do you mean by unique? You mean that it won't occur in any other document? You can't do that unless you use the id of the document.

On Monday, February 13, 2012 at 9:28 PM, Frank LaRosa wrote:

> Is this the solution?
> 
> .startObject("idea\_signature")  
> .field("type", "string")  
> .field("store", "yes")  
> .field("index", "not\_analyzed")  
> .endObject()
> 
> .startObject("\_id")  
> .field("path", "idea\_signature")  
> .endObject()
> 
> On Feb 13, 1:08 pm, Frank LaRosa \<[fr...@studyblue.com](mailto:fr...@studyblue.com) ([http://studyblue.com](http://studyblue.com))\> wrote:
> 
> > Hi,
> > 
> > Is it possible to make a field unique? I'm using the Java syntax, so  
> > my mapping definition looks like this:
> > 
> > .startObject("idea\_signature")  
> > .field("type", "string")  
> > .field("store", "yes")  
> > .field("index", "not\_analyzed")  
> > .endObject()
> > 
> > What do I need to do in order to make sure that this field is treated  
> > as a unique identifier? Thanks.

---

<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:** [July 6, 2017, 3:39am UTC](https://discuss.elastic.co/t/making-a-field-unique/6692/4 "2017-07-06T03:39:25Z")

</div>


