# opType create does not seem to create duplicates

**URL:** <https://discuss.elastic.co/t/optype-create-does-not-seem-to-create-duplicates/2976>\
**Category:** Elasticsearch\
**Created:** [May 26, 2010, 9:53am UTC](https://discuss.elastic.co/t/optype-create-does-not-seem-to-create-duplicates/2976 "2010-05-26T09:53:47Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Paul\_Loy](https://avatars.discourse-cdn.com/v4/letter/p/ad7895/32.png) [@Paul\_Loy](https://discuss.elastic.co/u/Paul_Loy)\
**Post date:** [May 26, 2010, 9:53am UTC](https://discuss.elastic.co/t/optype-create-does-not-seem-to-create-duplicates/2976/1 "2010-05-26T09:53:47Z")

</div>

Hi,

in the documentation[http://www.elasticsearch.com/docs/elasticsearch/rest\_api/index/#Operation\_Type](http://www.elasticsearch.com/docs/elasticsearch/rest_api/index/#Operation_Type)it  
states that:

"If the op\_type is set to create, and there is already an existing document

> with the same type and id within the index, the index will now hold _two_documents with the same id and type."

I do not see this in practice. If I do a \_status on the index after creating  
two documents with the same id and type it shows something like this:

"docs":{"num\_docs":1,"max\_doc":2,"deleted\_docs":1}

is the ?op\_type=create being honoured? or is there some cleanup task?

Thanks,

Paul

PS, here are my test REST calls, using 0.7.1:

-bash-3.2$ curl -XPUT '[http://127.0.0.1:9200/blogs/](http://127.0.0.1:9200/blogs/)'  
{"ok":true,"acknowledged":true}

-bash-3.2$ curl -XPUT '[http://127.0.0.1:9200/blogs/post/\_mapping](http://127.0.0.1:9200/blogs/post/_mapping)' -d '  
{  
post : {  
properties : {  
user : { type : "string", index : "not\_analyzed"},  
content : { type : "string", index : "analyzed"},  
postDate : { type : "date", format : "YYYYMMddHHmmSS", index :  
"analyzed" },  
tags : { type : "string", indexName : "tag", index : "not\_analyzed" }  
}  
}  
}  
'  
{"ok":true,"acknowledged":true}

-bash-3.2$ curl -XPUT '[http://127.0.0.1:9200/blogs/post/\*3\*?\*optype=create](http://127.0.0.1:9200/blogs/post/*3*?*optype=create)\*'  
-d '  
{  
post : {  
user : "keteracel",  
content : "This is my first blog post using Elasticsearch as the  
backing data store!

I hope you like it!

**Paul**.",  
postDate : "20100315193410",  
tags : ["blog","first","Elasticsearch"]  
}  
}  
'  
{"ok":true,"\_index":"blogs","\_type":"post","\_id":"3"}

-bash-3.2$ curl -XPUT '[http://127.0.0.1:9200/blogs/post/\*3\*?\*optype=create](http://127.0.0.1:9200/blogs/post/*3*?*optype=create)\*'  
-d '  
{  
post : {  
user : "keteracel"  
}  
}  
'  
{"ok":true,"\_index":"blogs","\_type":"post","\_id":"3"}

-bash-3.2$ curl -XGET '[http://localhost:9200/blogs/\_status](http://localhost:9200/blogs/_status)'  
{"ok":true,"\_shards":{"total":10,"successful":5,"failed":0},"indices":{"blogs":{"aliases":,"settings":{"index.number\_of\_shards":"5","index.number\_of\_replicas":"1"},"store\_size":"1.9k","store\_size\_in\_bytes":1949,"estimated\_flushable\_memory\_size":"382","estimated\_flushable\_memory\_size\_in\_bytes":382,"translog\_operations":2,  
_"docs":{"num\_docs":1,"max\_doc":2,"deleted\_docs":1}_  
,"shards":{"0":[{"routing":{"state":"STARTED","primary":true,"node":"f32e18a3-6ad1-4b33-bac1-b436d7f3b5a3","relocating\_node":null,"shard":0,"index":"blogs"},"state":"STARTED","store\_size":"52","store\_size\_in\_bytes":52,"estimated\_flushable\_memory\_size":"0","estimated\_flushable\_memory\_size\_in\_bytes":0,"translog\_id":0,"translog\_operations":0,"docs":{"num\_docs":0,"max\_doc":0,"deleted\_docs":0}}],"1":[{"routing":{"state":"STARTED","primary":true,"node":"f32e18a3-6ad1-4b33-bac1-b436d7f3b5a3","relocating\_node":null,"shard":1,"index":"blogs"},"state":"STARTED","store\_size":"52","store\_size\_in\_bytes":52,"estimated\_flushable\_memory\_size":"0","estimated\_flushable\_memory\_size\_in\_bytes":0,"translog\_id":0,"translog\_operations":0,"docs":{"num\_docs":0,"max\_doc":0,"deleted\_docs":0}}],"2":[{"routing":{"state":"STARTED","primary":true,"node":"f32e18a3-6ad1-4b33-bac1-b436d7f3b5a3","relocating\_node":null,"shard":2,"index":"blogs"},"state":"STARTED","store\_size":"1.7k","store\_size\_in\_bytes":1741,"estimated\_flushable\_memory\_size":"382","estimated\_flushable\_memory\_size\_in\_bytes":382,"translog\_id":0,"translog\_operations":2,"docs":{"num\_docs":1,"max\_doc":2,"deleted\_docs":1}}],"3":[{"routing":{"state":"STARTED","primary":true,"node":"f32e18a3-6ad1-4b33-bac1-b436d7f3b5a3","relocating\_node":null,"shard":3,"index":"blogs"},"state":"STARTED","store\_size":"52","store\_size\_in\_bytes":52,"estimated\_flushable\_memory\_size":"0","estimated\_flushable\_memory\_size\_in\_bytes":0,"translog\_id":0,"translog\_operations":0,"docs":{"num\_docs":0,"max\_doc":0,"deleted\_docs":0}}],"4":[{"routing":{"state":"STARTED","primary":true,"node":"f32e18a3-6ad1-4b33-bac1-b436d7f3b5a3","relocating\_node":null,"shard":4,"index":"blogs"},"state":"STARTED","store\_size":"52","store\_size\_in\_bytes":52,"estimated\_flushable\_memory\_size":"0","estimated\_flushable\_memory\_size\_in\_bytes":0,"translog\_id":0,"translog\_operations":0,"docs":{"num\_docs":0,"max\_doc":0,"deleted\_docs":0}}]}}}}

## --

Paul Loy  
[paul@keteracel.com](mailto:paul@keteracel.com)  
[http://www.keteracel.com/](http://www.keteracel.com/)

---

<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:** [May 26, 2010, 10:05am UTC](https://discuss.elastic.co/t/optype-create-does-not-seem-to-create-duplicates/2976/2 "2010-05-26T10:05:04Z")

</div>

The parameter should be op\_type, and no optype. Another option is to add  
\_create, for example: 'localhost:9200/index/type/id/\_create'.

On Wed, May 26, 2010 at 12:53 PM, Paul Loy [keteracel@gmail.com](mailto:keteracel@gmail.com) wrote:

> Hi,
> 
> in the documentation[http://www.elasticsearch.com/docs/elasticsearch/rest\_api/index/#Operation\_Type](http://www.elasticsearch.com/docs/elasticsearch/rest_api/index/#Operation_Type)it states that:
> 
> "If the op\_type is set to create, and there is already an existing
> 
> > document with the same type and id within the index, the index will now hold  
> > _two_ documents with the same id and type."
> 
> I do not see this in practice. If I do a \_status on the index after  
> creating two documents with the same id and type it shows something like  
> this:
> 
> "docs":{"num\_docs":1,"max\_doc":2,"deleted\_docs":1}
> 
> is the ?op\_type=create being honoured? or is there some cleanup task?
> 
> Thanks,
> 
> Paul
> 
> PS, here are my test REST calls, using 0.7.1:
> 
> -bash-3.2$ curl -XPUT '[http://127.0.0.1:9200/blogs/](http://127.0.0.1:9200/blogs/)'  
> {"ok":true,"acknowledged":true}
> 
> -bash-3.2$ curl -XPUT '[http://127.0.0.1:9200/blogs/post/\_mapping](http://127.0.0.1:9200/blogs/post/_mapping)' -d '  
> {  
> post : {  
> properties : {  
> user : { type : "string", index : "not\_analyzed"},  
> content : { type : "string", index : "analyzed"},  
> postDate : { type : "date", format : "YYYYMMddHHmmSS", index :  
> "analyzed" },  
> tags : { type : "string", indexName : "tag", index : "not\_analyzed" }  
> }  
> }  
> }  
> '  
> {"ok":true,"acknowledged":true}
> 
> -bash-3.2$ curl -XPUT '[http://127.0.0.1:9200/blogs/post/\*3\*?\*optype=create](http://127.0.0.1:9200/blogs/post/*3*?*optype=create)  
> \*' -d '  
> {  
> post : {  
> user : "keteracel",  
> content : "This is my first blog post using Elasticsearch as the  
> backing data store!
> 
> I hope you like it!
> 
> **Paul**.",  
> postDate : "20100315193410",  
> tags : ["blog","first","Elasticsearch"]  
> }  
> }  
> '  
> {"ok":true,"\_index":"blogs","\_type":"post","\_id":"3"}
> 
> -bash-3.2$ curl -XPUT '[http://127.0.0.1:9200/blogs/post/\*3\*?\*optype=create](http://127.0.0.1:9200/blogs/post/*3*?*optype=create)  
> \*' -d '  
> {  
> post : {  
> user : "keteracel"  
> }  
> }  
> '  
> {"ok":true,"\_index":"blogs","\_type":"post","\_id":"3"}
> 
> -bash-3.2$ curl -XGET '[http://localhost:9200/blogs/\_status](http://localhost:9200/blogs/_status)'
> 
> {"ok":true,"\_shards":{"total":10,"successful":5,"failed":0},"indices":{"blogs":{"aliases":,"settings":{"index.number\_of\_shards":"5","index.number\_of\_replicas":"1"},"store\_size":"1.9k","store\_size\_in\_bytes":1949,"estimated\_flushable\_memory\_size":"382","estimated\_flushable\_memory\_size\_in\_bytes":382,"translog\_operations":2,  
> _"docs":{"num\_docs":1,"max\_doc":2,"deleted\_docs":1}_  
> ,"shards":{"0":[{"routing":{"state":"STARTED","primary":true,"node":"f32e18a3-6ad1-4b33-bac1-b436d7f3b5a3","relocating\_node":null,"shard":0,"index":"blogs"},"state":"STARTED","store\_size":"52","store\_size\_in\_bytes":52,"estimated\_flushable\_memory\_size":"0","estimated\_flushable\_memory\_size\_in\_bytes":0,"translog\_id":0,"translog\_operations":0,"docs":{"num\_docs":0,"max\_doc":0,"deleted\_docs":0}}],"1":[{"routing":{"state":"STARTED","primary":true,"node":"f32e18a3-6ad1-4b33-bac1-b436d7f3b5a3","relocating\_node":null,"shard":1,"index":"blogs"},"state":"STARTED","store\_size":"52","store\_size\_in\_bytes":52,"estimated\_flushable\_memory\_size":"0","estimated\_flushable\_memory\_size\_in\_bytes":0,"translog\_id":0,"translog\_operations":0,"docs":{"num\_docs":0,"max\_doc":0,"deleted\_docs":0}}],"2":[{"routing":{"state":"STARTED","primary":true,"node":"f32e18a3-6ad1-4b33-bac1-b436d7f3b5a3","relocating\_node":null,"shard":2,"index":"blogs"},"state":"STARTED","store\_size":"1.7k","store\_size\_in\_bytes":1741,"estimated\_flushable\_memory\_size":"382","estimated\_flushable\_memory\_size\_in\_bytes":382,"translog\_id":0,"translog\_operations":2,"docs":{"num\_docs":1,"max\_doc":2,"deleted\_docs":1}}],"3":[{"routing":{"state":"STARTED","primary":true,"node":"f32e18a3-6ad1-4b33-bac1-b436d7f3b5a3","relocating\_node":null,"shard":3,"index":"blogs"},"state":"STARTED","store\_size":"52","store\_size\_in\_bytes":52,"estimated\_flushable\_memory\_size":"0","estimated\_flushable\_memory\_size\_in\_bytes":0,"translog\_id":0,"translog\_operations":0,"docs":{"num\_docs":0,"max\_doc":0,"deleted\_docs":0}}],"4":[{"routing":{"state":"STARTED","primary":true,"node":"f32e18a3-6ad1-4b33-bac1-b436d7f3b5a3","relocating\_node":null,"shard":4,"index":"blogs"},"state":"STARTED","store\_size":"52","store\_size\_in\_bytes":52,"estimated\_flushable\_memory\_size":"0","estimated\_flushable\_memory\_size\_in\_bytes":0,"translog\_id":0,"translog\_operations":0,"docs":{"num\_docs":0,"max\_doc":0,"deleted\_docs":0}}]}}}}
> 
> ## --
> 
> Paul Loy  
> [paul@keteracel.com](mailto:paul@keteracel.com)  
> [http://www.keteracel.com/](http://www.keteracel.com/)

---

<div class="post-metadata">

**Author:** ![Paul\_Loy](https://avatars.discourse-cdn.com/v4/letter/p/ad7895/32.png) [@Paul\_Loy](https://discuss.elastic.co/u/Paul_Loy)\
**Post date:** [May 26, 2010, 10:23am UTC](https://discuss.elastic.co/t/optype-create-does-not-seem-to-create-duplicates/2976/3 "2010-05-26T10:23:02Z")

</div>

Haha, how embarassing!

😃

Thanks!

On Wed, May 26, 2010 at 11:05 AM, Shay Banon  
[shay.banon@elasticsearch.com](mailto:shay.banon@elasticsearch.com)wrote:

> The parameter should be op\_type, and no optype. Another option is to add  
> \_create, for example: 'localhost:9200/index/type/id/\_create'.
> 
> On Wed, May 26, 2010 at 12:53 PM, Paul Loy [keteracel@gmail.com](mailto:keteracel@gmail.com) wrote:
> 
> > Hi,
> > 
> > in the documentation[http://www.elasticsearch.com/docs/elasticsearch/rest\_api/index/#Operation\_Type](http://www.elasticsearch.com/docs/elasticsearch/rest_api/index/#Operation_Type)it states that:
> > 
> > "If the op\_type is set to create, and there is already an existing
> > 
> > > document with the same type and id within the index, the index will now hold  
> > > _two_ documents with the same id and type."
> > 
> > I do not see this in practice. If I do a \_status on the index after  
> > creating two documents with the same id and type it shows something like  
> > this:
> > 
> > "docs":{"num\_docs":1,"max\_doc":2,"deleted\_docs":1}
> > 
> > is the ?op\_type=create being honoured? or is there some cleanup task?
> > 
> > Thanks,
> > 
> > Paul
> > 
> > PS, here are my test REST calls, using 0.7.1:
> > 
> > -bash-3.2$ curl -XPUT '[http://127.0.0.1:9200/blogs/](http://127.0.0.1:9200/blogs/)'  
> > {"ok":true,"acknowledged":true}
> > 
> > -bash-3.2$ curl -XPUT '[http://127.0.0.1:9200/blogs/post/\_mapping](http://127.0.0.1:9200/blogs/post/_mapping)' -d '  
> > {  
> > post : {  
> > properties : {  
> > user : { type : "string", index : "not\_analyzed"},  
> > content : { type : "string", index : "analyzed"},  
> > postDate : { type : "date", format : "YYYYMMddHHmmSS", index :  
> > "analyzed" },  
> > tags : { type : "string", indexName : "tag", index : "not\_analyzed" }  
> > }  
> > }  
> > }  
> > '  
> > {"ok":true,"acknowledged":true}
> > 
> > -bash-3.2$ curl -XPUT '[http://127.0.0.1:9200/blogs/post/\*3\*?](http://127.0.0.1:9200/blogs/post/*3*?)\*  
> > optype=create\*' -d '  
> > {  
> > post : {  
> > user : "keteracel",  
> > content : "This is my first blog post using Elasticsearch as the  
> > backing data store!
> > 
> > I hope you like it!
> > 
> > **Paul**.",  
> > postDate : "20100315193410",  
> > tags : ["blog","first","Elasticsearch"]  
> > }  
> > }  
> > '  
> > {"ok":true,"\_index":"blogs","\_type":"post","\_id":"3"}
> > 
> > -bash-3.2$ curl -XPUT '[http://127.0.0.1:9200/blogs/post/\*3\*?](http://127.0.0.1:9200/blogs/post/*3*?)\*  
> > optype=create\*' -d '  
> > {  
> > post : {  
> > user : "keteracel"  
> > }  
> > }  
> > '  
> > {"ok":true,"\_index":"blogs","\_type":"post","\_id":"3"}
> > 
> > -bash-3.2$ curl -XGET '[http://localhost:9200/blogs/\_status](http://localhost:9200/blogs/_status)'
> > 
> > {"ok":true,"\_shards":{"total":10,"successful":5,"failed":0},"indices":{"blogs":{"aliases":,"settings":{"index.number\_of\_shards":"5","index.number\_of\_replicas":"1"},"store\_size":"1.9k","store\_size\_in\_bytes":1949,"estimated\_flushable\_memory\_size":"382","estimated\_flushable\_memory\_size\_in\_bytes":382,"translog\_operations":2,  
> > _"docs":{"num\_docs":1,"max\_doc":2,"deleted\_docs":1}_  
> > ,"shards":{"0":[{"routing":{"state":"STARTED","primary":true,"node":"f32e18a3-6ad1-4b33-bac1-b436d7f3b5a3","relocating\_node":null,"shard":0,"index":"blogs"},"state":"STARTED","store\_size":"52","store\_size\_in\_bytes":52,"estimated\_flushable\_memory\_size":"0","estimated\_flushable\_memory\_size\_in\_bytes":0,"translog\_id":0,"translog\_operations":0,"docs":{"num\_docs":0,"max\_doc":0,"deleted\_docs":0}}],"1":[{"routing":{"state":"STARTED","primary":true,"node":"f32e18a3-6ad1-4b33-bac1-b436d7f3b5a3","relocating\_node":null,"shard":1,"index":"blogs"},"state":"STARTED","store\_size":"52","store\_size\_in\_bytes":52,"estimated\_flushable\_memory\_size":"0","estimated\_flushable\_memory\_size\_in\_bytes":0,"translog\_id":0,"translog\_operations":0,"docs":{"num\_docs":0,"max\_doc":0,"deleted\_docs":0}}],"2":[{"routing":{"state":"STARTED","primary":true,"node":"f32e18a3-6ad1-4b33-bac1-b436d7f3b5a3","relocating\_node":null,"shard":2,"index":"blogs"},"state":"STARTED","store\_size":"1.7k","store\_size\_in\_bytes":1741,"estimated\_flushable\_memory\_size":"382","estimated\_flushable\_memory\_size\_in\_bytes":382,"translog\_id":0,"translog\_operations":2,"docs":{"num\_docs":1,"max\_doc":2,"deleted\_docs":1}}],"3":[{"routing":{"state":"STARTED","primary":true,"node":"f32e18a3-6ad1-4b33-bac1-b436d7f3b5a3","relocating\_node":null,"shard":3,"index":"blogs"},"state":"STARTED","store\_size":"52","store\_size\_in\_bytes":52,"estimated\_flushable\_memory\_size":"0","estimated\_flushable\_memory\_size\_in\_bytes":0,"translog\_id":0,"translog\_operations":0,"docs":{"num\_docs":0,"max\_doc":0,"deleted\_docs":0}}],"4":[{"routing":{"state":"STARTED","primary":true,"node":"f32e18a3-6ad1-4b33-bac1-b436d7f3b5a3","relocating\_node":null,"shard":4,"index":"blogs"},"state":"STARTED","store\_size":"52","store\_size\_in\_bytes":52,"estimated\_flushable\_memory\_size":"0","estimated\_flushable\_memory\_size\_in\_bytes":0,"translog\_id":0,"translog\_operations":0,"docs":{"num\_docs":0,"max\_doc":0,"deleted\_docs":0}}]}}}}
> > 
> > ## --
> > 
> > Paul Loy  
> > [paul@keteracel.com](mailto:paul@keteracel.com)  
> > [http://www.keteracel.com/](http://www.keteracel.com/)

## --

Paul Loy  
[paul@keteracel.com](mailto:paul@keteracel.com)  
[http://www.keteracel.com/paul](http://www.keteracel.com/paul)

---

<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, 4:23am UTC](https://discuss.elastic.co/t/optype-create-does-not-seem-to-create-duplicates/2976/4 "2017-07-06T04:23:47Z")

</div>


