Question: I have an igraph network which I want to color with RColorBrewer. Vertices have a "sector" attribute, which I want to use to color them. To do this, I have defined a color palette based on sectors:

```
color.range <- brewer.pal(nlevels(as.factor(V(g)$sector)), name = "Dark2")
V(g)$color  <- color.range[as.factor(V(g)$sector)]

```

When I plot my graph, colors of the legend do not match the information in the "sector" attribute of my vertices:

```
plot.igraph(g,
        vertex.label = ifelse(V(g)$indegree > 5, V(g)$sector, NA),
        vertex.label.family = "Arial",
        vertex.label.color = "black",
        vertex.label.cex = 0.5,
        vertex.frame.color = NA,
        vertex.color = V(g)$color,
        vertex.size = 3,
        layout = layout.fruchterman.reingold,
        edge.arrow.mode = 1,
        edge.arrow.size = 0.2)

legend("topleft",
        legend = levels(as.factor(V(g)$sector)),
        col = levels(as.factor(V(g)$color)),
        pch = 19,
        cex = 0.8,
        title = "",
        bg="transparent",
        bty = "n")

```

On the plot I see the categories of some high degree vertices and comparing them with the legend, colors do not match:
[example plot where colors on graph do not match legend](https://i.stack.imgur.com/lEYES.png)

My question is: how can I define a color range that will actually match my sector categories OR how can I create a legend that represents colors properly. Unfortunately I don't know which one is the problem.

Answer: 
You can use the [`explain` parameter](https://www.elastic.co/guide/en/elasticsearch/reference/6.5/search-request-explain.html) to show how the score was computed. This shows the score for each hit, so it will give the fields that matched and the score.

```
{
  "explain": true,
  "query": {
    "bool": {
      "should": [
        { "bool": { ... } },
        { "bool": { ... } }
      ]
    }
  }
}

```
Thank you @Tim and @Val. I was looking for `named_queries`.

```
{
  "query": {
    "bool": {
      "should": [
        { "bool": { "_name": "x", "must": [ ... ] } },
        { "bool": { "_name": "y", "must": [ ... ] } },
      ]
    }
  }
}

```