# Composite search question and error (need help please)

**URL:** <https://discuss.elastic.co/t/composite-search-question-and-error-need-help-please/210078>\
**Category:** Elasticsearch\
**Created:** [December 1, 2019, 7:28pm UTC](https://discuss.elastic.co/t/composite-search-question-and-error-need-help-please/210078 "2019-12-01T19:28:20Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![iukea](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/iukea/32/49083_2.png) [@iukea](https://discuss.elastic.co/u/iukea)\
**Post date:** [December 1, 2019, 7:28pm UTC](https://discuss.elastic.co/t/composite-search-question-and-error-need-help-please/210078/1 "2019-12-01T19:28:20Z")

</div>

Hello Elastic bros

I am seeking some wisdom on setting up a composite search.

I am trying to filter out "OS\_Threat.IO\_Threats"

Below is my search quarry

```auto
GET logstash-*/_search
{
  "query": {
    "bool": {
      "must_not": {
        "match": {
          "type.keyword": "OS_Threat.IO_Threats"
        }
      },
      "must": {
        "range": {
          "timestamp": {
            "gte": "now-30d/d",
            "lt": "now/d"
          }
        }
      }
    }
  },
  "aggs": {
    "values": {
      "composite": {
        "size": 10,
        "sources": [
          {
            "src_ip.keyword": {
              "terms": {
                "field": "src_ip.keyword",
                "order": "asc"
              }
            }
          },
          {
            "geoip.country_name.keyword": {
              "terms": {
                "field": "geoip.country_name.keyword"
              }
            }
          },
          {
            "beat.name.keyword": {
              "terms": {
                "field": "beat.name.keyword"
              }
            }
          },
          {
            "type.keyword": {
              "terms": {
                "field": "type.keyword",
                "order": "asc"
              }
            }
          },
          {
            "ip_rep.keyword": {
              "terms": {
                "field": "ip_rep.keyword",
                "order": "asc"
              },
              "missing": " __missing__"
            }
          }
        ]
        },
        
      "aggs": {
        "firstseen": {
          "min": {
            "field": "@timestamp"
          }
        },
        "lastseen": {
          "max": {
            "field": "@timestamp"
          }
        }
      }
    }
  }
}

```

Currently getting the following error and I am bit stumped on what to teak in the quarry.

```auto
{
  "error": {
    "root_cause": [
      {
        "type": "x_content_parse_exception",
        "reason": "[61:13] [composite] failed to parse field [sources]"
      }
    ],
    "type": "x_content_parse_exception",
    "reason": "[61:13] [composite] failed to parse field [sources]",
    "caused_by": {
      "type": "illegal_state_exception",
      "reason": "expected value but got [END_OBJECT]"
    }
  },
  "status": 400
}

```

---

<div class="post-metadata">

**Author:** ![iukea](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/iukea/32/49083_2.png) [@iukea](https://discuss.elastic.co/u/iukea)\
**Post date:** [December 3, 2019, 12:06am UTC](https://discuss.elastic.co/t/composite-search-question-and-error-need-help-please/210078/2 "2019-12-03T00:06:23Z")

</div>

so removing the missing field seems to fix it but I would like the missing fields if possible

```
 {
                "_source": ["src_ip", "geoip.country_name", "beat.name", "type", "ip_rep"],
                "query": {
                    "bool": {
                        "must_not": {
                            "match": { "type.keyword": "OS_Threat.IO_Threats" }
                        },
                        "must": {
                            "range": {
                                "timestamp": {
                                    "gte": "now-30d/d",
                                    "lt": "now/d"
                                }
                            }
                        }
                    }
                },
                "aggs": {
                    "values": {
                        "composite": {
                            "size": 10000,
                            "sources": [
                                {
                                    "src_ip.keyword": {
                                        "terms": {
                                            "field": "src_ip.keyword",
                                            "order": "asc"
                                        }
                                    }
                                },
                                {
                                    "geoip.country_name.keyword": {
                                        "terms": {
                                            "field": "geoip.country_name.keyword"
                                        }
                                    }
                                },
                                {
                                    "beat.name.keyword": {
                                        "terms": {
                                            "field": "beat.name.keyword"
                                        }
                                    }
                                },
                                {
                                    "type.keyword": {
                                        "terms": {
                                            "field": "type.keyword",
                                            "order": "asc"
                                        }
                                    }
                                },
                                {
                                    "ip_rep.keyword": {
                                        "terms": {
                                            "field": "ip_rep.keyword"
                                        }
                                    }
                                }
                            ]
                        },
                        "aggs": {
                            "firstseen": {
                                "min": {
                                    "field": "@timestamp"
                                }
                            },
                            "lastseen": {
                                "max": {
                                    "field": "@timestamp"
                                }
                            }
                        }
                    }
                }
        }
```

---

<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 31, 2019, 12:06am UTC](https://discuss.elastic.co/t/composite-search-question-and-error-need-help-please/210078/3 "2019-12-31T00:06:24Z")

</div>

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