# How to select only one branch in bool query

**URL:** <https://discuss.elastic.co/t/how-to-select-only-one-branch-in-bool-query/242877>\
**Category:** Elasticsearch\
**Created:** [July 28, 2020, 10:18am UTC](https://discuss.elastic.co/t/how-to-select-only-one-branch-in-bool-query/242877 "2020-07-28T10:18:57Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![gitterhh](https://avatars.discourse-cdn.com/v4/letter/g/b19c9b/32.png) [@gitterhh](https://discuss.elastic.co/u/gitterhh)\
**Post date:** [July 28, 2020, 10:18am UTC](https://discuss.elastic.co/t/how-to-select-only-one-branch-in-bool-query/242877/1 "2020-07-28T10:18:58Z")

</div>

I have a list of documents

```auto
[
  {
    "shortName": "CA",
    "longName": "California"
  },
  {
    "shortName": "New York",
    "longName": "New York"
  },
]

```

How to configure the query to select only the first field that matches, something like `maximumSouldMatch`=1

For example if I search `New York`, it should match only `shortName` but not both, as in this case the score will be doubled

---

<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:** [August 3, 2020, 11:02am UTC](https://discuss.elastic.co/t/how-to-select-only-one-branch-in-bool-query/242877/2 "2020-08-03T11:02:20Z")

</div>

I suppose you are using the `nested` query. You may want to take a look at the [score\_mode](https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-nested-query.html) - I'm however not sure if that is exactly what you are searching for.

Sharing your mapping, index creation and query would probably 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:** [August 31, 2020, 11:02am UTC](https://discuss.elastic.co/t/how-to-select-only-one-branch-in-bool-query/242877/3 "2020-08-31T11:02:21Z")

</div>

Closed on August 31, 2020, 11:02am UTC

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