# Get The id of the ES document created by FSCrawler

**URL:** <https://discuss.elastic.co/t/get-the-id-of-the-es-document-created-by-fscrawler/278939>\
**Category:** Elasticsearch\
**Created:** [July 16, 2021, 6:57pm UTC](https://discuss.elastic.co/t/get-the-id-of-the-es-document-created-by-fscrawler/278939 "2021-07-16T18:57:15Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Francois\_Saab](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/francois_saab/32/91763_2.png) [@Francois\_Saab](https://discuss.elastic.co/u/Francois_Saab)\
**Post date:** [July 16, 2021, 6:57pm UTC](https://discuss.elastic.co/t/get-the-id-of-the-es-document-created-by-fscrawler/278939/1 "2021-07-16T18:57:15Z")

</div>

When FSCrawler sends a document to ES, i need to associate the \_id of the doc created by FSCrawler with an internal ID in our DB.

How to get the \_id of the doc created by FSCrawler each time a new document is being indexed?

Is there a way for FSCrawler to call a method in my code after a document is being indexed? and send to that method informations (e.g. \_id,...) that are related to the newly indexed document.

Is it possible to specify to FSCrawler the \_id of the doc that it will create in ES.

Thanks

---

<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:** [July 22, 2021, 2:20pm UTC](https://discuss.elastic.co/t/get-the-id-of-the-es-document-created-by-fscrawler/278939/2 "2021-07-22T14:20:57Z")

</div>

Welcome!

One of the thing you could do is to use the REST Service of FSCrawler.

> Is it possible to specify to FSCrawler the \_id of the doc that it will create in ES.

Then you can manually set the id of the document (see [REST service — FSCrawler 2.10-SNAPSHOT documentation](https://fscrawler.readthedocs.io/en/latest/admin/fs/rest.html#document-id)).

> How to get the \_id of the doc created by FSCrawler each time a new document is being indexed?

Or read the response object sent by FSCrawler which looks like:

```auto
{
  "ok" : true,
  "filename" : "test.txt",
  "url" : "http://127.0.0.1:9200/fscrawler-rest-tests_doc/doc/dd18bf3a8ea2a3e53e2661c7fb53534"
}

```

Would that work for you?  
But that means that you will have to do the "crawl" part by yourself as in that case, FSCrawler is "just" a gateway to elasticsearch.

---

<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:** [August 19, 2021, 2:21pm UTC](https://discuss.elastic.co/t/get-the-id-of-the-es-document-created-by-fscrawler/278939/3 "2021-08-19T14:21:19Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
