# Embed highlighter

**URL:** <https://discuss.elastic.co/t/embed-highlighter/212566>\
**Category:** Elasticsearch\
**Created:** [December 19, 2019, 9:23pm UTC](https://discuss.elastic.co/t/embed-highlighter/212566 "2019-12-19T21:23:45Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![fabio.vianello](https://avatars.discourse-cdn.com/v4/letter/f/b5e925/32.png) [@fabio.vianello](https://discuss.elastic.co/u/fabio.vianello)\
**Post date:** [December 19, 2019, 9:23pm UTC](https://discuss.elastic.co/t/embed-highlighter/212566/1 "2019-12-19T21:23:45Z")

</div>

Hi everyone, I need help.  
I have to incorporate the highlighter is this my code on node.jd thanks

app.get('/search', function (req, res) {  
let body = {  
size: 100,  
from: 0,  
query: {  
bool: {  
\_id: ,  
must: [

```
      {
        "bool": {
          "should": [
            { "match": { title: req.query['q'] } },
            // { "match": { title: req.query['q'] } },
            { "match": { content: req.query['q'] } },
            { "match": { nome: req.query['q'] } },
            { "match": { cognome: req.query['q'] } },
            { "match": { dateToDay: req.query['q'] } },
            { "match": { groupName: req.query['q'] } }
          ]
        }

      }
      ,

      {
        "bool": {
          "must": [
            { "match": { userid: req.user.id } }
            //,
            //{ "match": { useridPadre: req.user.id } },

          ]
        }
      }

    ]
  }
}
// ,

// "highlight": {
// "require_field_match": true,
// "fields": {
// "content":{}
// }
// }

```

}

client.search({ body: body })// con index  
.then(results =\> {  
res.send(results.hits.hits);

```
})
.catch(err => {
  console.log(err)
  res.send([]);
});

```

})

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [December 20, 2019, 9:15am UTC](https://discuss.elastic.co/t/embed-highlighter/212566/2 "2019-12-20T09:15:44Z")

</div>

please take your time to properly format your snippets. This is super hard to read.

Also, please mention what error messages are being returned when you try to add highlighting, this is super useful for debugging.

Also, have you tried to run that query in the kibana console (not in your programming language) just to see if it works in principle? That's usually a good start before trying to do this in any programming language.

---

<div class="post-metadata">

**Author:** ![fabio.vianello](https://avatars.discourse-cdn.com/v4/letter/f/b5e925/32.png) [@fabio.vianello](https://discuss.elastic.co/u/fabio.vianello)\
**Post date:** [December 20, 2019, 9:56am UTC](https://discuss.elastic.co/t/embed-highlighter/212566/3 "2019-12-20T09:56:27Z")

</div>

hi, this query does work bat don't see the highlight. thanks  
GET /\_search?q='aws'  
{  
"query": {  
"bool": {  
"\_id": ,  
"must": [

```
      {
        "bool": {
          "should": [
            { "match": { "title": "aws" }},
            { "match": { "content": "aws" } },
            { "match": { "nome": "aws" } },
            { "match": { "cognome": "aws" } },
            { "match": { "dateToDay": "aws" } },
            { "match": { "groupName": "aws" } }
          ]
        }

      }
      ,

      {
        "bool": {
          "must": [
            { "match": { "userid": "5df6079a570a0b0017aea0e7" } }
          ]
        }
      }
    ]
  }
},
"highlight" : {
    "fields" : {
        "title" : {}
    }
}

```

}

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [December 20, 2019, 10:08am UTC](https://discuss.elastic.co/t/embed-highlighter/212566/4 "2019-12-20T10:08:33Z")

</div>

can you share a fully reproducible example including index creation/mapping/document indexing, please? Thanks!

---

<div class="post-metadata">

**Author:** ![fabio.vianello](https://avatars.discourse-cdn.com/v4/letter/f/b5e925/32.png) [@fabio.vianello](https://discuss.elastic.co/u/fabio.vianello)\
**Post date:** [December 21, 2019, 10:07am UTC](https://discuss.elastic.co/t/embed-highlighter/212566/5 "2019-12-21T10:07:49Z")

</div>

[quote="spinscale, post:4, topic:212566, full:true"]  
can you share a fully reproducible example including index creation/mapping/document indexing, please? Thanks!

Hi, sorry if I'm not precise in what they ask me I'm new on elasticsearch.  
The following is the code in node.js which it uses to create snippets. As you notice index = null.  
Thank you

Fabio

Client.index({  
index: "null",  
//id: '1',  
//type: 'constituencies',

```
      body: {
        "name": String(req.body.name),
        "surname": String(req.body.surname),
        "imageAccount": imageAccount1,
        //'String(req.body.imageAccount),

        "dateToDay": dataForm,
        "userid": arrayUser, //ho tolto le quadre
        // "userid": [String(list1)],

        "useridPadre": String(req.user.id),
        "title": String(req.body.title),
        "content": String(req.body.contenuto),
        // "allBody": (String(req.body.title) +
        // ' ' + String(req.body.content)),
        "show": false,
        "idGruppo": req.body.ddlGroup,
        "groupName": nota.nomeGruppo,
        "nome": String(nomeUt),
        "cognome": String(cognomeUt),
        "publicationState": req.body.DDLpublicationState

      }
```

---

<div class="post-metadata">

**Author:** ![fabio.vianello](https://avatars.discourse-cdn.com/v4/letter/f/b5e925/32.png) [@fabio.vianello](https://discuss.elastic.co/u/fabio.vianello)\
**Post date:** [December 29, 2019, 8:52pm UTC](https://discuss.elastic.co/t/embed-highlighter/212566/6 "2019-12-29T20:52:04Z")

</div>

good evening, can you help me?

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [January 8, 2020, 10:09am UTC](https://discuss.elastic.co/t/embed-highlighter/212566/7 "2020-01-08T10:09:53Z")

</div>

I'm sorry, but this is not a fully reproducible example. See [https://www.elastic.co/help](https://www.elastic.co/help)

---

<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:** [February 5, 2020, 10:10am UTC](https://discuss.elastic.co/t/embed-highlighter/212566/8 "2020-02-05T10:10:02Z")

</div>

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