# Suggestions for reindexing individual documents

**URL:** <https://discuss.elastic.co/t/suggestions-for-reindexing-individual-documents/5595>\
**Category:** Elasticsearch\
**Created:** [October 13, 2011, 7:55pm UTC](https://discuss.elastic.co/t/suggestions-for-reindexing-individual-documents/5595 "2011-10-13T19:55:09Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Shane\_Witbeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/shane_witbeck/32/2803_2.png) [@Shane\_Witbeck](https://discuss.elastic.co/u/Shane_Witbeck)\
**Post date:** [October 13, 2011, 7:55pm UTC](https://discuss.elastic.co/t/suggestions-for-reindexing-individual-documents/5595/1 "2011-10-13T19:55:09Z")

</div>

I'm in the process of indexing some forums via the Java API. What's  
the recommended way to re-index individual documents? Could someone  
explain the steps necessary for doing this? Even better, if there's an  
example using the Java API showing this common use case, I'd be  
interested in seeing that too.

Thanks,  
Shane

---

<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:** [October 14, 2011, 12:27pm UTC](https://discuss.elastic.co/t/suggestions-for-reindexing-individual-documents/5595/2 "2011-10-14T12:27:22Z")

</div>

First, how do you know which documents you need to reindex? Also, do you  
want to reindex them based on the data stored in elasticsearch itself, or  
based on "outside" data?

If you have hte docs that need to be reindexed in a database, for example,  
just fetch them from it, and index those docs again.

If its simply based on their IDs and index it from elasticsearch, you can  
simply use the Get / Multi Get API to fetch the docs, change then, and index  
it again (you can use versioning to make sure no other updates have happened  
in between).

If its based on a query, you can execute the search query, possibly using  
the scan search type (  
[Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/java-api/search.html)) and  
reindex the docs that match it.

On Thu, Oct 13, 2011 at 9:55 PM, Shane Witbeck [shane@digitalsanctum.com](mailto:shane@digitalsanctum.com)wrote:

> I'm in the process of indexing some forums via the Java API. What's  
> the recommended way to re-index individual documents? Could someone  
> explain the steps necessary for doing this? Even better, if there's an  
> example using the Java API showing this common use case, I'd be  
> interested in seeing that too.
> 
> Thanks,  
> Shane

---

<div class="post-metadata">

**Author:** ![Shane\_Witbeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/shane_witbeck/32/2803_2.png) [@Shane\_Witbeck](https://discuss.elastic.co/u/Shane_Witbeck)\
**Post date:** [October 15, 2011, 1:28pm UTC](https://discuss.elastic.co/t/suggestions-for-reindexing-individual-documents/5595/3 "2011-10-15T13:28:27Z")

</div>

Thanks for the reply. Im planning on firing events whenever a forum  
thread changes. An event listener will simply refetch the data for  
that thread from the DB and reindex. It seems easier to get the  
existing ES doc (indexed by threadID), delete it (if it exists) and re-  
index a new doc with the changed data. Is this acceptable and if so is  
there any additional steps I'm missing such as refreshing the index?

Thanks again,  
Shane

On Oct 14, 8:27 am, Shay Banon [kim...@gmail.com](mailto:kim...@gmail.com) wrote:

> First, how do you know which documents you need to reindex? Also, do you  
> want to reindex them based on the data stored in elasticsearch itself, or  
> based on "outside" data?
> 
> If you have hte docs that need to be reindexed in a database, for example,  
> just fetch them from it, and index those docs again.
> 
> If its simply based on their IDs and index it from elasticsearch, you can  
> simply use the Get / Multi Get API to fetch the docs, change then, and index  
> it again (you can use versioning to make sure no other updates have happened  
> in between).
> 
> If its based on a query, you can execute the search query, possibly using  
> the scan search type ([Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/java-api/search.html)) and  
> reindex the docs that match it.
> 
> On Thu, Oct 13, 2011 at 9:55 PM, Shane Witbeck [sh...@digitalsanctum.com](mailto:sh...@digitalsanctum.com)wrote:
> 
> > I'm in the process of indexing some forums via the Java API. What's  
> > the recommended way to re-index individual documents? Could someone  
> > explain the steps necessary for doing this? Even better, if there's an  
> > example using the Java API showing this common use case, I'd be  
> > interested in seeing that too.
> 
> > Thanks,  
> > Shane

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [October 15, 2011, 2:12pm UTC](https://discuss.elastic.co/t/suggestions-for-reindexing-individual-documents/5595/4 "2011-10-15T14:12:01Z")

</div>

You don't have to delete the old version of your document. Just push the new one.

David 😉

Le 15 oct. 2011 à 15:28, Shane Witbeck [shane@digitalsanctum.com](mailto:shane@digitalsanctum.com) a écrit :

> Thanks for the reply. Im planning on firing events whenever a forum  
> thread changes. An event listener will simply refetch the data for  
> that thread from the DB and reindex. It seems easier to get the  
> existing ES doc (indexed by threadID), delete it (if it exists) and re-  
> index a new doc with the changed data. Is this acceptable and if so is  
> there any additional steps I'm missing such as refreshing the index?
> 
> Thanks again,  
> Shane
> 
> On Oct 14, 8:27 am, Shay Banon [kim...@gmail.com](mailto:kim...@gmail.com) wrote:
> 
> > First, how do you know which documents you need to reindex? Also, do you  
> > want to reindex them based on the data stored in elasticsearch itself, or  
> > based on "outside" data?
> > 
> > If you have hte docs that need to be reindexed in a database, for example,  
> > just fetch them from it, and index those docs again.
> > 
> > If its simply based on their IDs and index it from elasticsearch, you can  
> > simply use the Get / Multi Get API to fetch the docs, change then, and index  
> > it again (you can use versioning to make sure no other updates have happened  
> > in between).
> > 
> > If its based on a query, you can execute the search query, possibly using  
> > the scan search type ([Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/java-api/search.html)) and  
> > reindex the docs that match it.
> > 
> > On Thu, Oct 13, 2011 at 9:55 PM, Shane Witbeck [sh...@digitalsanctum.com](mailto:sh...@digitalsanctum.com)wrote:
> > 
> > > I'm in the process of indexing some forums via the Java API. What's  
> > > the recommended way to re-index individual documents? Could someone  
> > > explain the steps necessary for doing this? Even better, if there's an  
> > > example using the Java API showing this common use case, I'd be  
> > > interested in seeing that too.
> > 
> > > Thanks,  
> > > Shane

---

<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, 3:51am UTC](https://discuss.elastic.co/t/suggestions-for-reindexing-individual-documents/5595/5 "2017-07-06T03:51:50Z")

</div>


