# Document Preview in elasticsearch

**URL:** <https://discuss.elastic.co/t/document-preview-in-elasticsearch/259242>\
**Category:** Elastic Search\
**Tags:** elastic-workplace-search\
**Created:** [December 21, 2020, 10:33am UTC](https://discuss.elastic.co/t/document-preview-in-elasticsearch/259242 "2020-12-21T10:33:08Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![sagar.pattnayak](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sagar.pattnayak/32/94542_2.png) [@sagar.pattnayak](https://discuss.elastic.co/u/sagar.pattnayak)\
**Post date:** [December 21, 2020, 10:33am UTC](https://discuss.elastic.co/t/document-preview-in-elasticsearch/259242/1 "2020-12-21T10:33:08Z")

</div>

Hi There,  
I am new to Elasticsearch. I do have 10 years of experience in SharePoint search. I wanted to know if there is any OOB feature availabe to preview documents those appear in search results in stead of really opening them.

I search for APIs but seems it is not there. Anyone aware of this? Or knows if we have to build something custom what we need to start with.

Preview is an important feature of our existing search application with features to highlight searched keyword and its synonyms in the preview pane.

Any pointers is highly appreciated.

Best  
Sagar

---

<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:** [December 21, 2020, 12:13pm UTC](https://discuss.elastic.co/t/document-preview-in-elasticsearch/259242/2 "2020-12-21T12:13:19Z")

</div>

Welcome!

I moved your question to #enterprise-search:workplace-search as I think there are some features available in [Workplace Search](https://www.elastic.co/workplace-search) for this.

---

<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:** [December 21, 2020, 3:50pm UTC](https://discuss.elastic.co/t/document-preview-in-elasticsearch/259242/3 "2020-12-21T15:50:23Z")

</div>

Thanks, @dadoonet!

Hi, @sagar.pattnayak! Elastic Workplace Search comes with a SharePoint Online connector, out-of-the-box. You can read the documentation for it here: [https://www.elastic.co/guide/en/workplace-search/current/workplace-search-sharepoint-online-connector.html](https://www.elastic.co/guide/en/workplace-search/current/workplace-search-sharepoint-online-connector.html)

When you first connect, almost immediately you'll start seeing entries appear in our search UI that _do not_ have preview/sample text. Not to worry! A background process is running that will (more slowly) extract the textual content for your files and make it visible in the search UI. You'll get the text highlighting and sample text that you're used to from other search experiences. How long this takes to appear depends on your data size, but it should be in the range of minutes-hours.

Hopefully that helps!

---

<div class="post-metadata">

**Author:** ![sagar.pattnayak](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sagar.pattnayak/32/94542_2.png) [@sagar.pattnayak](https://discuss.elastic.co/u/sagar.pattnayak)\
**Post date:** [December 22, 2020, 6:52am UTC](https://discuss.elastic.co/t/document-preview-in-elasticsearch/259242/4 "2020-12-22T06:52:15Z")

</div>

Hi @Sean_Story  
Thanks for your response. However our requirement is a bit different. SharePoint is just one of the source system for our search application. We do have documents from other sources like (VeevaVault, OpenText Documentum, FileShare) with different file formats like pdf, doc/x, xls/x, ppt/x and the customer wants preview for all.

Also we are using Elastic just as index. We have our own UI component where we need to integrate preview for all sources and all above file types.

---

<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:** [December 22, 2020, 9:44am UTC](https://discuss.elastic.co/t/document-preview-in-elasticsearch/259242/5 "2020-12-22T09:44:35Z")

</div>

You can use Workplace Search API to run your search so you can integrate it easily in your own application. See:

> **[Search API Reference | Workplace Search Guide \[7.10\] | Elastic](https://www.elastic.co/guide/en/workplace-search/current/workplace-search-search-api.html)**

But, if you don't want to use workplace search and its content sources (see below)

> **[Content Sources Overview | Workplace Search Guide \[7.10\] | Elastic](https://www.elastic.co/guide/en/workplace-search/current/workplace-search-content-sources.html)**

Then you need to do "manually" everything that workplace search does out of the box:

- Read from the source (VeevaVault, OpenText Documentum, FileShare, ...)
- Extract the text and metadata information (See below)
- Generate a preview
- Index all that information in elasticsearch

To extract the text and metadata, you can use the [ingest attachment plugin](https://www.elastic.co/guide/en/elasticsearch/plugins/current/ingest-attachment.html).

There an example here: [https://www.elastic.co/guide/en/elasticsearch/plugins/current/using-ingest-attachment.html](https://www.elastic.co/guide/en/elasticsearch/plugins/current/using-ingest-attachment.html)

```auto
PUT _ingest/pipeline/attachment
{
  "description" : "Extract attachment information",
  "processors" : [
    {
      "attachment" : {
        "field" : "data"
      }
    }
  ]
}
PUT my_index/_doc/my_id?pipeline=attachment
{
  "data": "e1xydGYxXGFuc2kNCkxvcmVtIGlwc3VtIGRvbG9yIHNpdCBhbWV0DQpccGFyIH0="
}
GET my_index/_doc/my_id

```

The `data` field is basically the BASE64 representation of your binary file.

You can use [FSCrawler](https://fscrawler.readthedocs.io). There's [a tutorial](https://fscrawler.readthedocs.io/en/latest/user/tutorial.html) to help you getting started.

---

<div class="post-metadata">

**Author:** ![sagar.pattnayak](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sagar.pattnayak/32/94542_2.png) [@sagar.pattnayak](https://discuss.elastic.co/u/sagar.pattnayak)\
**Post date:** [December 22, 2020, 11:16am UTC](https://discuss.elastic.co/t/document-preview-in-elasticsearch/259242/6 "2020-12-22T11:16:40Z")

</div>

Thanks @dadoonet  
I will try this and see.

---

<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:** [January 19, 2021, 11:16am UTC](https://discuss.elastic.co/t/document-preview-in-elasticsearch/259242/7 "2021-01-19T11:16:54Z")

</div>

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