Making a field unique


(Frank LaRosa) #1

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.


(Frank LaRosa) #2

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 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.


(Shay Banon) #3

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 (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.


(system) #4