adamfairholm / Elasticquent

Map Larvel Eloquent models to Elasticsearch types
MIT License
201 stars 38 forks source link

Add "Partial-Update" Function #35

Open stevenay opened 9 years ago

stevenay commented 9 years ago

Normally if we want to update an existing document, we have to reindex or replace it.

By ElasticSearch's update API, it can be able to do partial updates to a document. This update API is more efficient and reliable. According to *"elastic" guide,

"The difference is that this process happens within a shard, thus avoiding the network overhead of multiple requests. By reducing the time between the retrieve and reindex steps, we also reduce the likelihood of there being conflicting changes from other processes."

In this updateIndex(), existing scalar fields (columns) are overwritten, and new fields (columns) are added to the index.