/elasticsearch-partialupdate

an elasticsearch plugin that allows to update a specify fileds of a document,avoid full reindex and reduce traffic costs

Primary LanguageJava

ElasticSearch PartialUpdate Plugin

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>0.16.2</elasticsearch.version>
...
  • maven build
mvn clean
mvn package
  • install the plugin
  • drop the jar file to your elasticsearch plugin folder:
    elasticsearch/plguin/es-partial-update/

or

bin/plugin  -install wayne530/elasticsearch-partialupdate

how to play with this plugin?

  • first,let’s index a doucument
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/_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"}}