# Easy question for you experts - need help with a query

**URL:** <https://discuss.elastic.co/t/easy-question-for-you-experts-need-help-with-a-query/381990>\
**Category:** Elastic Search\
**Created:** [September 16, 2025, 6:37pm UTC](https://discuss.elastic.co/t/easy-question-for-you-experts-need-help-with-a-query/381990 "2025-09-16T18:37:24Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![HaroldMelamed](https://avatars.discourse-cdn.com/v4/letter/h/4da419/32.png) [@HaroldMelamed](https://discuss.elastic.co/u/HaroldMelamed)\
**Post date:** [September 16, 2025, 6:37pm UTC](https://discuss.elastic.co/t/easy-question-for-you-experts-need-help-with-a-query/381990/1 "2025-09-16T18:37:24Z")

</div>

I’m trying to do a search on multiple fields in collection. This is what I tried. How do I fix this?

> ```
> search_query = {
> 
> "query": {
> 
> "match": {
> 
> "RunID": RunID,
> 
> "host": host_name
> 
> }
> 
> }
> 
> }
> 
> ```

---

<div class="post-metadata">

**Author:** ![Kathleen\_DeRusso](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kathleen_derusso/32/132039_2.png) [@Kathleen\_DeRusso](https://discuss.elastic.co/u/Kathleen_DeRusso)\
**Post date:** [September 16, 2025, 6:59pm UTC](https://discuss.elastic.co/t/easy-question-for-you-experts-need-help-with-a-query/381990/2 "2025-09-16T18:59:14Z")

</div>

Hey there @HaroldMelamed and welcome to the community! You may want to check out our [multi-match query](https://www.elastic.co/docs/reference/query-languages/query-dsl/query-dsl-multi-match-query), that should get you what you want for the same search string. Or a [boolean](https://www.elastic.co/docs/reference/query-languages/query-dsl/query-dsl-bool-query) query for multiple terms. Happy searching!

---

<div class="post-metadata">

**Author:** ![HaroldMelamed](https://avatars.discourse-cdn.com/v4/letter/h/4da419/32.png) [@HaroldMelamed](https://discuss.elastic.co/u/HaroldMelamed)\
**Post date:** [September 16, 2025, 7:10pm UTC](https://discuss.elastic.co/t/easy-question-for-you-experts-need-help-with-a-query/381990/3 "2025-09-16T19:10:45Z")

</div>

what I’m looking for is to search two different fields in a single query with different search criteria. For example

(runID = 12324 and host = LRE)

---

<div class="post-metadata">

**Author:** ![stephenb](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/stephenb/32/40856_2.png) [@stephenb](https://discuss.elastic.co/u/stephenb)\
**Post date:** [September 16, 2025, 7:50pm UTC](https://discuss.elastic.co/t/easy-question-for-you-experts-need-help-with-a-query/381990/4 "2025-09-16T19:50:07Z")

</div>

Hi @HaroldMelamed

@Kathleen_DeRusso gave you the correct answer using a `bool`

```auto
{
  "query": {
    "bool" : {
      "must" : {
        "term" : { "runID" : "12324" },
         "term" : { "host" : "LRE" }

      },
.... 

```

---

<div class="post-metadata">

**Author:** ![HaroldMelamed](https://avatars.discourse-cdn.com/v4/letter/h/4da419/32.png) [@HaroldMelamed](https://discuss.elastic.co/u/HaroldMelamed)\
**Post date:** [September 16, 2025, 8:09pm UTC](https://discuss.elastic.co/t/easy-question-for-you-experts-need-help-with-a-query/381990/5 "2025-09-16T20:09:32Z")

</div>

Thank you very much the exact query. I need even the most basic help these days. At my age it appears that my brain is full . 😀

---

<div class="post-metadata">

**Author:** ![stephenb](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/stephenb/32/40856_2.png) [@stephenb](https://discuss.elastic.co/u/stephenb)\
**Post date:** [September 16, 2025, 10:07pm UTC](https://discuss.elastic.co/t/easy-question-for-you-experts-need-help-with-a-query/381990/6 "2025-09-16T22:07:19Z")

</div>

All good ... Many of the free LLMs are a great place to start with helping to write queries.

---

<div class="post-metadata">

**Author:** ![HaroldMelamed](https://avatars.discourse-cdn.com/v4/letter/h/4da419/32.png) [@HaroldMelamed](https://discuss.elastic.co/u/HaroldMelamed)\
**Post date:** [September 17, 2025, 3:20am UTC](https://discuss.elastic.co/t/easy-question-for-you-experts-need-help-with-a-query/381990/7 "2025-09-17T03:20:43Z")

</div>

here at the bank we aren’t doing AI yet. They promised soon. Thanks for the idea!!

---

<div class="post-metadata">

**Author:** ![HaroldMelamed](https://avatars.discourse-cdn.com/v4/letter/h/4da419/32.png) [@HaroldMelamed](https://discuss.elastic.co/u/HaroldMelamed)\
**Post date:** [September 17, 2025, 6:08pm UTC](https://discuss.elastic.co/t/easy-question-for-you-experts-need-help-with-a-query/381990/8 "2025-09-17T18:08:55Z")

</div>

@stephenb

The code works but VSCODE isn’t appreciative of the code.

> ```
> search_query = {
> 
> "query": {
> 
> "bool": {
> 
> "must": {
> 
> "term": {"runID": RunID},
> 
> "term": {"host": host_name}
> 
> }
> 
> }
> 
> }
> 
> }
> 
> ```

![image](https://us1.discourse-cdn.com/elastic/original/3X/e/9/e90edeb7c7cce573135954f16e89f28da8310e74.png)

---

<div class="post-metadata">

**Author:** ![Kathleen\_DeRusso](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kathleen_derusso/32/132039_2.png) [@Kathleen\_DeRusso](https://discuss.elastic.co/u/Kathleen_DeRusso)\
**Post date:** [September 17, 2025, 7:06pm UTC](https://discuss.elastic.co/t/easy-question-for-you-experts-need-help-with-a-query/381990/9 "2025-09-17T19:06:46Z")

</div>

If you look at the API docs for the bool query linked above, I think you’re missing some { } to denote objects in json for each term query.

---

<div class="post-metadata">

**Author:** ![stephenb](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/stephenb/32/40856_2.png) [@stephenb](https://discuss.elastic.co/u/stephenb)\
**Post date:** [September 17, 2025, 7:52pm UTC](https://discuss.elastic.co/t/easy-question-for-you-experts-need-help-with-a-query/381990/10 "2025-09-17T19:52:16Z")

</div>

Working Example ... sorry I wrote that first one on my phone  
You need the array bracket `[]`

If you Go into Kibana Dev Tools, the Smart Editor will help with all that..  
If you are trying to write DSL outside of that, you will likely make many mistakes 🙂

```auto
POST my_index/_doc
{
  "foo" : "fooish",
  "bar" : "barish"

}

POST my_index/_doc
{
  "foo" : "fooish",
  "bar" : "notbarish"

}

GET my_index/_search
{
  "query": {
    "bool": {
      "must": [
        {
          "term": {
            "foo": "fooish"
          }
        },
        {
          "term": {
            "bar": "barish"
          }
        }
      ]
    }
  }
}

```
