# Request of field + value & samefield + anothervalue combinations using bool must or query\_string - ask for help

**URL:** <https://discuss.elastic.co/t/request-of-field-value-samefield-anothervalue-combinations-using-bool-must-or-query-string-ask-for-help/215395>\
**Category:** Elasticsearch\
**Created:** [January 16, 2020, 11:18pm UTC](https://discuss.elastic.co/t/request-of-field-value-samefield-anothervalue-combinations-using-bool-must-or-query-string-ask-for-help/215395 "2020-01-16T23:18:08Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Datakids](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/datakids/32/39622_2.png) [@Datakids](https://discuss.elastic.co/u/Datakids)\
**Post date:** [January 16, 2020, 11:18pm UTC](https://discuss.elastic.co/t/request-of-field-value-samefield-anothervalue-combinations-using-bool-must-or-query-string-ask-for-help/215395/1 "2020-01-16T23:18:08Z")

</div>

Hi,  
i just tried to build following request to count documents containing player active status but no match found:

```
GET /players/_search    
{
  "size": 0,
  "query": {
    "bool": {
        "must" : [
            {"terms" : { "player" : ["576","234"]}},
            {"terms": { "active": ["y", "z"]}}
        ]
    }
  }
}

```

Ends up in zero hits!

Ok then I tried this to test wheter one of each serves a result:

```
GET /players/_search
{
  "size": 10,
    "query": {
        "query_string" : {
            "fields" : ["player", "active"],
            "query" : "576 AND y"
        }
    }
}

"hits" : {
    "total" : {
      "value" : 56,
      "relation" : "eq"
    },

then 

GET /players/_search
{
  "size": 10,
    "query": {
        "query_string" : {
            "fields" : ["player", "active"],
            "query" : "234 AND z"
        }
    }
}

"hits" : {
    "total" : {
      "value" : 13,
      "relation" : "eq"
    },

```

But I need booth in combination to the other which should end in 2 hits  
means this 2 different players had an active status of y and z at the same time  
and I need to find them to build testcases.

How can I ?  
Thanks and Brdgs

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [January 17, 2020, 6:08am UTC](https://discuss.elastic.co/t/request-of-field-value-samefield-anothervalue-combinations-using-bool-must-or-query-string-ask-for-help/215395/2 "2020-01-17T06:08:07Z")

</div>

Could you provide a full recreation script as described in [About the Elasticsearch category](https://discuss.elastic.co/t/about-the-elasticsearch-category/21). It will help to better understand what you are doing. Please, try to keep the example as simple as possible.

A full reproduction script will help readers to understand, reproduce and if needed fix your problem. It will also most likely help to get a faster answer.

---

<div class="post-metadata">

**Author:** ![Datakids](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/datakids/32/39622_2.png) [@Datakids](https://discuss.elastic.co/u/Datakids)\
**Post date:** [January 17, 2020, 9:02am UTC](https://discuss.elastic.co/t/request-of-field-value-samefield-anothervalue-combinations-using-bool-must-or-query-string-ask-for-help/215395/3 "2020-01-17T09:02:50Z")

</div>

Hi David,  
I'll try:

ES v7.5.1

My Mapping:

```
{
  "players" : {
    "mappings" : {
      "properties" : {
        "@timestamp" : {
          "type" : "date"
        },
        "@version" : {
          "type" : "text",
          "fields" : {
            "keyword" : {
              "type" : "keyword",
              "ignore_above" : 256
            }
          }
        },
        "player" : {
          "type" : "text",
          "fields" : {
            "keyword" : {
              "type" : "keyword",
              "ignore_above" : 256
            }
          }
        },
        "active" : {
          "type" : "text",
          "fields" : {
            "keyword" : {
              "type" : "keyword",
              "ignore_above" : 256
            }
          }
        },
        "server" : {
          "type" : "text",
          "fields" : {
            "keyword" : {
              "type" : "keyword",
              "ignore_above" : 256
            }
          }
        }
      }
    }
  }
}

```

Cause I'm not sure how to create a recreation script to match all I want I try to explain this way:

![grafik](https://us1.discourse-cdn.com/elastic/original/3X/5/7/57b91ecef7b9c4cb5b1dbc9393dbb028634cd04a.png)

I want to find the "4" and or the "2" depending on output fields:

},"\_source": ["server", "player"]

or  
},"\_source": ["server"]

or  
},"\_source": ["player"]

I hope this is a little more understandable.

Thanks  
Regards

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [January 17, 2020, 11:18am UTC](https://discuss.elastic.co/t/request-of-field-value-samefield-anothervalue-combinations-using-bool-must-or-query-string-ask-for-help/215395/4 "2020-01-17T11:18:23Z")

</div>

Please provide something we can use to reproduce and fix your problem.  
We can make some assumptions but it's easier and faster if you provide everything we just have to copy/paste and run.

As the example I shared (see the link), you should have in the script:

- delete index
- index creation with mappings if any
- documents creation
- search requests

Thanks

---

<div class="post-metadata">

**Author:** ![Datakids](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/datakids/32/39622_2.png) [@Datakids](https://discuss.elastic.co/u/Datakids)\
**Post date:** [January 25, 2020, 10:53am UTC](https://discuss.elastic.co/t/request-of-field-value-samefield-anothervalue-combinations-using-bool-must-or-query-string-ask-for-help/215395/5 "2020-01-25T10:53:11Z")

</div>

HI dadoonet,  
first thanks for your reply and appologize my late!  
I do trie to explain what I meant but due to my lack of knowledge of how ES is working behind the scene when writing an index my pain ends in how to explain the case and further I thought that might be more a Kibana question.

Therefore closed here and thanks  
Regards

---

<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 22, 2020, 10:53am UTC](https://discuss.elastic.co/t/request-of-field-value-samefield-anothervalue-combinations-using-bool-must-or-query-string-ask-for-help/215395/6 "2020-02-22T10:53:15Z")

</div>

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