Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
an elasticsearch plugin that allows to update a specify fileds of a document,avoid full reindex and reduce traffic costs
Java
branch: master
Failed to load latest commit information.
lib fix maven config
src/main update to support es 1.0.0
.gitignore rename
README.textile fix readme
pom.xml update to support es 1.0.0

README.textile

ElasticSearch PartialUpdate Plugin

NOTE elasticsearch 0.19 already implemented a update action,check it out:
http://www.elasticsearch.org/guide/reference/api/update.html

//version:1.0.0 is for es0.16.2,
//version 1.1.1 is for es0.19.4
//version 1.2.0 is for es0.90.2
//version 1.2.2 is for es1.0.0

//changelog:
//2012-07-08 change all rest interface “_update” to “_partial_update”.(breaking change!)
//2014.2.26 array merge support

Update your index on-demand.

how to build this plugin?

  • specify elasticsearch version

by edit pom.xml,you can specify the elasticsearch version you are using.

...
<elasticsearch.version>1.0.0</elasticsearch.version>
...
  • maven build
mvn clean
mvn package
  • install the plugin
  • drop the jar file to your elasticsearch plugin folder:
    elasticsearch/plugin/es-partial-update/
  • versions
partial update Plugin ElasticSearch
master 1.0.0 → master
1.2.2 1.0.0
1.2.1 0.90.2
1.1.1 0.19.4
1.1.0 0.19.0
1.0.0 0.18.x

how to play with this plugin?

  • first,let’s index a document
curl -XDELETE http://localhost:9200/index/type1/1/
curl -XPOST http://localhost:9200/index/type1/1/ -d'{"name":"medcl","blog":"http://log.medcl.net"}'

{"ok":true,"_index":"index","_type":"type1","_id":"1","_version":1}
  • now let’s get it
curl -XGET http://localhost:9200/index/type1/1/

{"_index":"index","_type":"type1","_id":"1","_version":1, "_source" : {"name":"medcl","blog":"http://log.medcl.net"}}
  • ok,let’s update it,update a filed(name),and add a new filed(time)
curl -XPOST http://localhost:9200/index/type1/1/_partial_update -d'{"name":"medcl?","time":"2011-1-1"}'

{"ok":true,"_index":"index","_type":"type1","_id":"1","_version":2}
  • let’s get the document again,and you can see,the document is already changed.
curl -XGET http://localhost:9200/index/type1/1/

{"_index":"index","_type":"type1","_id":"1","_version":2, "_source" : {"time":"2011-1-1","name":"medcl?","blog":"http://log.medcl.net"}}

how to play with array merge?

  • add a new tag,data type is array
curl -XPOST http://localhost:9200/index/type1/1/_partial_update -d'{"tag":["test"]}'
  • now check it
curl -XGET http://localhost:9200/index/type1/1/

{"_index":"index","_type":"type1","_id":"1","_version":39,"exists":true, "_source" : {"blog":"http://log.medcl.net","name":"medcl?","tag":["test"],"time":"2011-1-1"}}
  • update the tag field,add new tag `movie`
curl -XPOST http://localhost:9200/index/type1/1/_partial_update/append -d'{"tag":["movie"]}'
  • now check it again
curl -XGET http://localhost:9200/index/type1/1/

{"_index":"index","_type":"type1","_id":"1","_version":40,"exists":true, "_source" : {"blog":"http://log.medcl.net","name":"medcl?","tag":["test","movie"],"time":"2011-1-1"}}

as you can see,movie is in.

  • let’s remove `test` from tag
curl -XPOST http://localhost:9200/index/type1/1/_partial_update/remove -d'{"tag":["test"]}'
  • check it again.
curl -XGET http://localhost:9200/index/type1/1/

{"_index":"index","_type":"type1","_id":"1","_version":41,"exists":true, "_source" : {"blog":"http://log.medcl.net","name":"medcl?","tag":["movie"],"time":"2011-1-1"}}

have fun.

Something went wrong with that request. Please try again.