# Index openxml structured documents with Elasticsearch

**URL:** <https://discuss.elastic.co/t/index-openxml-structured-documents-with-elasticsearch/254445>\
**Category:** Elasticsearch\
**Created:** [November 5, 2020, 5:53pm UTC](https://discuss.elastic.co/t/index-openxml-structured-documents-with-elasticsearch/254445 "2020-11-05T17:53:00Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![vhd.afr](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/vhd.afr/32/78490_2.png) [@vhd.afr](https://discuss.elastic.co/u/vhd.afr)\
**Post date:** [November 5, 2020, 5:53pm UTC](https://discuss.elastic.co/t/index-openxml-structured-documents-with-elasticsearch/254445/1 "2020-11-05T17:53:00Z")

</div>

We have a set of structured documents. The structure is extremely inspired by [openxml data model](http://officeopenxml.com/WPparagraph.php). Briefly speaking, documents are made up of an ordered set of paragraphs, each paragraph itself has id and an ordered set of runs and each run has a textual content and some metadata.

For instance, the following sample document contains two ["Lorem i **psu** m" , "dolor sit amet"] paragraphs.

```auto
      {
        id: 1
        paragraphs : [
            {
                title: "De finibus"
                runs: [
                    {text: "Lorem i", metadata: {} }, 
                    {text: "psu", metadata: {bold: true} }, 
                    {text: "m", metadata: {} }, 
                ] 
            },
            {
                id: 2
                runs: [
                    {text: "dolor sit amet", metadata: {} }, 
                ] 
            },
        ]
    }

```

We want to index the documents by Elasticsearch, of course, in a way such that it be able to answer the following queries:

1. Query: `dolor sit`

2. Query: `ipsum`

3. Query: `ipsum dolor`

I familiar with [nested](https://www.elastic.co/guide/en/elasticsearch/reference/current/nested.html) field in elastic. It may satisfy the first query. But how should we map our documents to connect the consecutive runs and paragraphs together and make elastic to answer two latter queries?

**NOTE:** I also asked this question in [Stackoverflow.com](http://Stackoverflow.com)(see [here](https://stackoverflow.com/questions/64697745/index-openxml-structured-documents-with-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:** [December 3, 2020, 5:53pm UTC](https://discuss.elastic.co/t/index-openxml-structured-documents-with-elasticsearch/254445/2 "2020-12-03T17:53:04Z")

</div>

Closed on December 3, 2020, 5:53pm UTC

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