# How to retrieve all document form a content source of Workplace search

**URL:** <https://discuss.elastic.co/t/how-to-retrieve-all-document-form-a-content-source-of-workplace-search/286834>\
**Category:** Elastic Search\
**Tags:** elastic-workplace-search\
**Created:** [October 15, 2021, 12:49pm UTC](https://discuss.elastic.co/t/how-to-retrieve-all-document-form-a-content-source-of-workplace-search/286834 "2021-10-15T12:49:36Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mymail\_Cpn](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mymail_cpn/32/82423_2.png) [@Mymail\_Cpn](https://discuss.elastic.co/u/Mymail_Cpn)\
**Post date:** [October 15, 2021, 12:49pm UTC](https://discuss.elastic.co/t/how-to-retrieve-all-document-form-a-content-source-of-workplace-search/286834/1 "2021-10-15T12:49:36Z")

</div>

Hello  
I am new to Elasticsearch.  
Yesterday I created content source and inserted few documents in workplace search.

Now I am trying to retrieve all the documents from that content source. What is the api that I need to use.  
I tried couple and everything is erring out please help.

---

<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, 2021, 1:11pm UTC](https://discuss.elastic.co/t/how-to-retrieve-all-document-form-a-content-source-of-workplace-search/286834/2 "2021-10-15T13:11:11Z")

</div>

You need to use the search API. [Search API Reference | Workplace Search Guide [7.15] | Elastic](https://www.elastic.co/guide/en/workplace-search/current/workplace-search-search-api.html)

But I don't think there's a way to extract **all** the documents. What would be the use case for this?

---

<div class="post-metadata">

**Author:** ![Mymail\_Cpn](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mymail_cpn/32/82423_2.png) [@Mymail\_Cpn](https://discuss.elastic.co/u/Mymail_Cpn)\
**Post date:** [October 15, 2021, 1:48pm UTC](https://discuss.elastic.co/t/how-to-retrieve-all-document-form-a-content-source-of-workplace-search/286834/3 "2021-10-15T13:48:41Z")

</div>

I was trying to show a demo to my team about workplace search today.

As part of it I wanted to show them all the documents that I inserted in to my content source.

so I was trying to find a way to retrieve all the documents in a custom content source that I created similar to select \* from a table.

---

<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, 2021, 2:14pm UTC](https://discuss.elastic.co/t/how-to-retrieve-all-document-form-a-content-source-of-workplace-search/286834/4 "2021-10-15T14:14:25Z")

</div>

Why not just using the standard user interface? I think that'd help to run such a demo.

---

<div class="post-metadata">

**Author:** ![Mymail\_Cpn](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mymail_cpn/32/82423_2.png) [@Mymail\_Cpn](https://discuss.elastic.co/u/Mymail_Cpn)\
**Post date:** [October 15, 2021, 2:28pm UTC](https://discuss.elastic.co/t/how-to-retrieve-all-document-form-a-content-source-of-workplace-search/286834/5 "2021-10-15T14:28:49Z")

</div>

True, I was thinking about the same.  
but I read the we can retrieve with index like  
curl -X GET "https://{YOUR\_SERVER}:9200/{YOUR\_INDEX}\_search" -H 'Content-Type: application/json' -d

but how do I find index of my content source

---

<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, 2021, 3:00pm UTC](https://discuss.elastic.co/t/how-to-retrieve-all-document-form-a-content-source-of-workplace-search/286834/6 "2021-10-15T15:00:33Z")

</div>

You should not use directly Elasticsearch when you are using workplace search.

But have a look at this API:

```
GET /_cat/indices?v

```

One of the internal indices is the one you are looking for. Check by the number of documents to find its name. Can't recall from the top of my head.

---

<div class="post-metadata">

**Author:** ![Mymail\_Cpn](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mymail_cpn/32/82423_2.png) [@Mymail\_Cpn](https://discuss.elastic.co/u/Mymail_Cpn)\
**Post date:** [October 15, 2021, 3:31pm UTC](https://discuss.elastic.co/t/how-to-retrieve-all-document-form-a-content-source-of-workplace-search/286834/7 "2021-10-15T15:31:13Z")

</div>

Worked...... I was able to get all my documents along with many more information.

I completely agree with you, that I should not use Elasticsearch. My use case is to get familiar with workplace search and evaluate whether we can incorporate in our organization.

So there is no way in workplace search at present to get info of my documents? If I want to update some document and If I don't remember its unique id then what are my options?

---

<div class="post-metadata">

**Author:** ![Sean\_Story](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sean_story/32/69987_2.png) [@Sean\_Story](https://discuss.elastic.co/u/Sean_Story)\
**Post date:** [October 15, 2021, 4:02pm UTC](https://discuss.elastic.co/t/how-to-retrieve-all-document-form-a-content-source-of-workplace-search/286834/8 "2021-10-15T16:02:15Z")

</div>

> [@Mymail\_Cpn](#):
>
> So there is no way in workplace search at present to get info of my documents? If I want to update some document and If I don't remember its unique id then what are my options?

Good question, @Mymail_Cpn.

1. One option is to provide the documents with meaningful IDs when you index them. Then you can use the [Get document by ID API](https://www.elastic.co/guide/en/workplace-search/current/workplace-search-content-sources-api.html#get-document-by-id-api) to retrieve them.
2. Another option is to use the [Search API](https://www.elastic.co/guide/en/workplace-search/current/workplace-search-search-api.html) as @dadoonet originally suggested. With an empty query term, this will return the first 100 documents, and with pagination you can use it to "list" up to 10k documents. Note that since this is a "search", documents that tie in score may be returned in different orders, depending on which shard is queried under the hood.
3. Be patient. 🙂 You're not the first to request a List All Documents API, and we are working to introduce one. However the desire to return results in a consistent order and allow you to scan though an arbitrarily large dataset has some fun and complex technical considerations, which is why it wasn't added originally. Hopefully this will be available in a release soon.

I hope this is helpful!

---

<div class="post-metadata">

**Author:** ![Mymail\_Cpn](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mymail_cpn/32/82423_2.png) [@Mymail\_Cpn](https://discuss.elastic.co/u/Mymail_Cpn)\
**Post date:** [October 15, 2021, 4:24pm UTC](https://discuss.elastic.co/t/how-to-retrieve-all-document-form-a-content-source-of-workplace-search/286834/9 "2021-10-15T16:24:31Z")

</div>

Thank you for providing me with some options. And relieved to hear that I am not the first person to ask.  
1. I tried your first option to retrieve a single document by its Id. It worked wonderfully.  
2. About the second option search API,  
POST /api/ws/v1/search  
I get below error :  
`{ "error" : "no handler found for uri [/api/ws/v1/search?pretty=true] and method [POST]" }`

---

<div class="post-metadata">

**Author:** ![Sean\_Story](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sean_story/32/69987_2.png) [@Sean\_Story](https://discuss.elastic.co/u/Sean_Story)\
**Post date:** [October 15, 2021, 4:38pm UTC](https://discuss.elastic.co/t/how-to-retrieve-all-document-form-a-content-source-of-workplace-search/286834/10 "2021-10-15T16:38:39Z")

</div>

> [@Mymail\_Cpn](#):
>
> 1. About the second option search API,  
> POST /api/ws/v1/search  
> I get below error :  
> `{ "error" : "no handler found for uri [/api/ws/v1/search?pretty=true] and method [POST]" }`

That error looks like you may have run it from Kibana dev tools? You can't currently use the Kibana dev tools to interact with Enterprise Search APIs - you'll need to use something like CUrl. Like:

```auto
curl -X POST http://localhost:3002/api/ws/v1/search \
-H "Authorization: Bearer $ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{
  "query": ""
}'

```

Note that the `ACCESS_TOKEN` here is retrieved by going through an OAuth flow. See: [Building Custom Search Experiences | Workplace Search Guide [7.16] | Elastic](https://www.elastic.co/guide/en/workplace-search/7.x/building-custom-search-workplace-search.html#configuring-search-oauth)

---

<div class="post-metadata">

**Author:** ![Mymail\_Cpn](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mymail_cpn/32/82423_2.png) [@Mymail\_Cpn](https://discuss.elastic.co/u/Mymail_Cpn)\
**Post date:** [October 15, 2021, 7:54pm UTC](https://discuss.elastic.co/t/how-to-retrieve-all-document-form-a-content-source-of-workplace-search/286834/11 "2021-10-15T19:54:09Z")

</div>

Yes, you were right I was running it through Kibana dev tools.  
Thank you for providing me detail instruction it was very helpful.

---

<div class="post-metadata">

**Author:** ![Sean\_Story](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sean_story/32/69987_2.png) [@Sean\_Story](https://discuss.elastic.co/u/Sean_Story)\
**Post date:** [October 19, 2021, 2:59pm UTC](https://discuss.elastic.co/t/how-to-retrieve-all-document-form-a-content-source-of-workplace-search/286834/12 "2021-10-19T14:59:18Z")

</div>

> [@Sean\_Story](#):
>
> Be patient. 🙂 You're not the first to request a List All Documents API, and we are working to introduce one.

Good news, @Mymail_Cpn! I can now share that the `List Documents API` is coming soon! While not yet released, we have put the documentation for it out to the public: see [Listing Documents](https://www.elastic.co/guide/en/workplace-search/7.x/workplace-search-custom-sources-api.html#list-documents).  
This typically indicates that the feature will be available in the next release. So stay tuned!

---

<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:** [November 16, 2021, 2:59pm UTC](https://discuss.elastic.co/t/how-to-retrieve-all-document-form-a-content-source-of-workplace-search/286834/13 "2021-11-16T14:59:55Z")

</div>

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