# Can a nested attachment type be highlighted?

**URL:** <https://discuss.elastic.co/t/can-a-nested-attachment-type-be-highlighted/16778>\
**Category:** Elasticsearch\
**Created:** [April 2, 2014, 10:27pm UTC](https://discuss.elastic.co/t/can-a-nested-attachment-type-be-highlighted/16778 "2014-04-02T22:27:17Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Pratikshya\_Kuinkel](https://avatars.discourse-cdn.com/v4/letter/p/eada6e/32.png) [@Pratikshya\_Kuinkel](https://discuss.elastic.co/u/Pratikshya_Kuinkel)\
**Post date:** [April 2, 2014, 10:27pm UTC](https://discuss.elastic.co/t/can-a-nested-attachment-type-be-highlighted/16778/1 "2014-04-02T22:27:17Z")

</div>

I am new to elasticsearch, so I may not be constructing the mapping in a  
correct way. But, my mapping looks as follows:

/myindex/messages/\_mapping

{

```
“messages“: {

    "properties": {

        "author": {

            "type": "String"

        },

        “pipe_id": {

            "type": "String"

        },

        "files": {                

                "type": "nested",

                "properties": {

                    "file" : {

                        "type": "attachment", 

                        "path": "full", 

                        "fields":

                        {

                        "file_author": {

                            "type": "String"

                        },

                        "file_id": {

                            "type": "String"

                        },

                        "file_mimetype": {

                            "type": "String"

                        },

                        "filename": {

                            "type": "String"

                        },

                        "content" : { 

```

"term\_vector":"with\_positions\_offsets", "store":"yes", "type": "String" }

```
                        }

                    }

                }

        },

        "tags": {

            "properties": {

                "tag_id": {

                    "type": "String"

                },

                "tag_name": {

                    "type": "String"

                }

            },

            "type": "nested"

        },

        "email": {

            "type": "String"

        },

        “message_description": {

            "type": "String"

        },

        “message_title": {

            "type": "String"

        }

    }

}

```

}

Now I have indexed the document and been able to search correctly on the  
attachments. But the highlighting on the "content" does not work. My query  
is as follows:

POST /myindex/messages/\_search

{

```
"query" : {

"query_string" : {

  "query" : "music"

}

```

},

"highlight": {

```
  "fields": {

      "files.file.content" : {}

  }

```

}

}

It matches the term "music" in my file and displays the base 64 encoded  
string but there is no highlight field. Please suggest if my mapping is  
correct and why am I not getting the highlighted result?

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/ff20aab1-0502-469d-9985-f69e271d875a%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/ff20aab1-0502-469d-9985-f69e271d875a%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Pratikshya\_Kuinkel](https://avatars.discourse-cdn.com/v4/letter/p/eada6e/32.png) [@Pratikshya\_Kuinkel](https://discuss.elastic.co/u/Pratikshya_Kuinkel)\
**Post date:** [April 4, 2014, 6:19am UTC](https://discuss.elastic.co/t/can-a-nested-attachment-type-be-highlighted/16778/2 "2014-04-04T06:19:58Z")

</div>

I solved this problem by setting "include\_in\_root" to "true" for the nested  
attachment.

On Thursday, April 3, 2014 9:27:17 AM UTC+11, Pratikshya Kuinkel wrote:

> I am new to elasticsearch, so I may not be constructing the mapping in a  
> correct way. But, my mapping looks as follows:
> 
> /myindex/messages/\_mapping
> 
> {
> 
> ```
> “messages“: {
> 
> "properties": {
> 
> "author": {
> 
> "type": "String"
> 
> },
> 
> “pipe_id": {
> 
> "type": "String"
> 
> },
> 
> "files": {                
> 
> "type": "nested",
> 
> "properties": {
> 
> "file" : {
> 
> "type": "attachment", 
> 
> "path": "full", 
> 
> "fields":
> 
> {
> 
> "file_author": {
> 
> "type": "String"
> 
> },
> 
> "file_id": {
> 
> "type": "String"
> 
> },
> 
> "file_mimetype": {
> 
> "type": "String"
> 
> },
> 
> "filename": {
> 
> "type": "String"
> 
> },
> 
> "content" : { 
> 
> ```
> 
> "term\_vector":"with\_positions\_offsets", "store":"yes", "type": "String" }
> 
> ```
> }
> 
> }
> 
> }
> 
> },
> 
> "tags": {
> 
> "properties": {
> 
> "tag_id": {
> 
> "type": "String"
> 
> },
> 
> "tag_name": {
> 
> "type": "String"
> 
> }
> 
> },
> 
> "type": "nested"
> 
> },
> 
> "email": {
> 
> "type": "String"
> 
> },
> 
> “message_description": {
> 
> "type": "String"
> 
> },
> 
> “message_title": {
> 
> "type": "String"
> 
> }
> 
> }
> 
> }
> 
> ```
> 
> }
> 
> Now I have indexed the document and been able to search correctly on the  
> attachments. But the highlighting on the "content" does not work. My query  
> is as follows:
> 
> POST /myindex/messages/\_search
> 
> {
> 
> ```
> "query" : {
> 
> "query_string" : {
> 
> "query" : "music"
> 
> }
> 
> ```
> 
> },
> 
> "highlight": {
> 
> ```
> "fields": {
> 
> "files.file.content" : {}
> 
> }
> 
> ```
> 
> }
> 
> }
> 
> It matches the term "music" in my file and displays the base 64 encoded  
> string but there is no highlight field. Please suggest if my mapping is  
> correct and why am I not getting the highlighted result?

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/e84afc1f-c04d-43af-8f4a-c2a334afaf4b%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/e84afc1f-c04d-43af-8f4a-c2a334afaf4b%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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, 1:38am UTC](https://discuss.elastic.co/t/can-a-nested-attachment-type-be-highlighted/16778/3 "2017-07-06T01:38:16Z")

</div>


