# Simple reindexing problem when data is updated

**URL:** <https://discuss.elastic.co/t/simple-reindexing-problem-when-data-is-updated/11763>\
**Category:** Elasticsearch\
**Created:** [May 1, 2013, 8:38am UTC](https://discuss.elastic.co/t/simple-reindexing-problem-when-data-is-updated/11763 "2013-05-01T08:38:43Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Stanley\_Chiang](https://avatars.discourse-cdn.com/v4/letter/s/4af34b/32.png) [@Stanley\_Chiang](https://discuss.elastic.co/u/Stanley_Chiang)\
**Post date:** [May 1, 2013, 8:38am UTC](https://discuss.elastic.co/t/simple-reindexing-problem-when-data-is-updated/11763/1 "2013-05-01T08:38:43Z")

</div>

hopefully this is just me being a noob as i am new to ES

when i add or edit an entry to an already indexed model, i find that they  
only way to get the updated search results is by completely reindexing  
everything. Is there a way to get this to automatically update the entry if  
i'm not changing the actual mapping? i.e. when the webapp is running and a  
user adds a new entry they should be able to search with the data from the  
entry they just entered without the admin having to manually reindex the  
entire thing.

thanks ahead of time for your time and expertise.

some background:  
i'm running:  
ruby 1.9.3p125  
Rails 3.2.12

i watched railscast 306/307  
and set my model as such:

class User \< ActiveRecord::Base

has\_many :ingredients, :dependent =\> :destroy  
has\_many :foods, :dependent =\> :destroy  
has\_many :stocks, :dependent =\> :destroy

include Tire::Model::Search  
include Tire::Model::Callbacks

def self.search(params)  
tire.search(load: true) do  
query { string params[:query], default\_operator: "AND" } if  
params[:query].present?  
end  
end

```
mapping do
indexes :username, type: 'string'
indexes :user_type, type: 'string'
indexes :description, type: 'string'
indexes :rating, type: 'integer'
indexes :email, type: 'string'
indexes :cuisine, type: 'string'

indexes :foods do
  indexes :name, type: 'string'
end

```

end

```
indexes :ingredients do
  indexes :ingredient_name, type: 'string'
end

```

# Define the JSON serialization

# 

def to\_indexed\_json  
to\_json( include: { ingredients: { only: [:ingredient\_name]  
} ,  
foods: { only: [:name]  
},  
stocks:{ only: [:ingredient\_name]  
}  
} )  
end

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<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, 2:38am UTC](https://discuss.elastic.co/t/simple-reindexing-problem-when-data-is-updated/11763/2 "2017-07-06T02:38:53Z")

</div>

Closed on July 6, 2017, 2:38am UTC


