# Problem implementing EuiSearchBar, cannot create queries with multiple boolean operators

**URL:** <https://discuss.elastic.co/t/problem-implementing-euisearchbar-cannot-create-queries-with-multiple-boolean-operators/248112>\
**Category:** Kibana\
**Tags:** kql-kibana-query-language\
**Created:** [September 10, 2020, 6:13am UTC](https://discuss.elastic.co/t/problem-implementing-euisearchbar-cannot-create-queries-with-multiple-boolean-operators/248112 "2020-09-10T06:13:39Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![K\_Chaitanya](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/k_chaitanya/32/46387_2.png) [@K\_Chaitanya](https://discuss.elastic.co/u/K_Chaitanya)\
**Post date:** [September 10, 2020, 6:13am UTC](https://discuss.elastic.co/t/problem-implementing-euisearchbar-cannot-create-queries-with-multiple-boolean-operators/248112/1 "2020-09-10T06:13:40Z")

</div>

I am trying to create a Kibana plugin, where I need do search on entire page, similar to that of search in Discover app. But query formed using the `EuiSearchBar` from elastic eui components

I have the following setup implemented.

```auto
    const initialQuery = EuiSearchBar.Query.MATCH_ALL;
    const [query, setQuery] = useState(initialQuery);
    const [error, setError] = useState(null);

```

```auto
    const schema = {
            strict: true,
            fields: {
                "_id": {
                    type: 'string'
                },
                "@timestamp": {
                    type: 'string'
                },
                "src.user": {
                    type: 'string'
                },
                "event.name": {
                    type: 'string'
                },
                "event.count": { 
                    type: 'string'
                },
            },
        };

```

```auto
    const onChange = ({ query, error }) => {
        if (error) {
            setError(error);
        } else {
            setError(null);
            setQuery(query);
        }
    };

```

```auto
   <EuiSearchBar className="fl ft p10 mt10 ml10"
    defaultQuery={initialQuery}
    box={{
            placeholder: 'e.g: type the Group Name',
            incremental: true,
            schema,
        }}
    onChange={onChange}
    />

```

when I write the query in search bar like this

 ![MicrosoftTeams-image](https://us1.discourse-cdn.com/elastic/original/3X/4/f/4fa7f206f3be0dd1d94a5eb5d7ece0a0715d7e3d.png)

I get query something like this.

```auto
{
  "bool": {
    "must": [
      {
        "simple_query_string": {
          "query": "and"
        }
      },
      {
        "match": {
          "_id": {
            "query": "w91gbnQBNaptJ3V4XcXG",
            "operator": "and"
          }
        }
      },
      {
        "range": {
          "event.count": {
            "gt": "400"
          }
        }
      }
    ]
  }
}

```

but I want it to be :

```auto
{
  "bool": {
    "must": [
      {
        "match": {
          "_id": {
            "query": "w91gbnQBNaptJ3V4XcXG",
            "operator": "and" // "and", "or" or "not" depending on the operator used in the query as it is there in the discovery
          }
        }
      },
      {
        "range": {
          "event.count": {
            "gt": "400"
          }
        }
      }
    ]
  }
}

```

---

<div class="post-metadata">

**Author:** ![wylie](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/wylie/32/81794_2.png) [@wylie](https://discuss.elastic.co/u/wylie)\
**Post date:** [September 10, 2020, 4:29pm UTC](https://discuss.elastic.co/t/problem-implementing-euisearchbar-cannot-create-queries-with-multiple-boolean-operators/248112/2 "2020-09-10T16:29:36Z")

</div>

EuiSearchBar has its own grammar which builds Elasticsearch queries, and in that grammar `and` has no meaning, it's just text, because all phrases are combined with `and` by default.

---

<div class="post-metadata">

**Author:** ![K\_Chaitanya](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/k_chaitanya/32/46387_2.png) [@K\_Chaitanya](https://discuss.elastic.co/u/K_Chaitanya)\
**Post date:** [September 11, 2020, 7:10am UTC](https://discuss.elastic.co/t/problem-implementing-euisearchbar-cannot-create-queries-with-multiple-boolean-operators/248112/3 "2020-09-11T07:10:23Z")

</div>

Thanks for the reply,

Is there way to customize the grammar? so that `EuiSearchBar` can understand other boolean operators.

---

<div class="post-metadata">

**Author:** ![wylie](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/wylie/32/81794_2.png) [@wylie](https://discuss.elastic.co/u/wylie)\
**Post date:** [September 11, 2020, 4:31pm UTC](https://discuss.elastic.co/t/problem-implementing-euisearchbar-cannot-create-queries-with-multiple-boolean-operators/248112/4 "2020-09-11T16:31:32Z")

</div>

EuiSearchBar already supports AND and OR, but AND is implicit. The documentation is here [https://elastic.github.io/eui/#/forms/search-bar](https://elastic.github.io/eui/#/forms/search-bar)

---

<div class="post-metadata">

**Author:** ![praveer](https://avatars.discourse-cdn.com/v4/letter/p/41988e/32.png) [@praveer](https://discuss.elastic.co/u/praveer)\
**Post date:** [September 17, 2020, 3:31pm UTC](https://discuss.elastic.co/t/problem-implementing-euisearchbar-cannot-create-queries-with-multiple-boolean-operators/248112/5 "2020-09-17T15:31:53Z")

</div>

Can you help us in how to show suggestions in search bar. It would be help full for user to understand the syntax of search query.

---

<div class="post-metadata">

**Author:** ![wylie](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/wylie/32/81794_2.png) [@wylie](https://discuss.elastic.co/u/wylie)\
**Post date:** [September 17, 2020, 6:24pm UTC](https://discuss.elastic.co/t/problem-implementing-euisearchbar-cannot-create-queries-with-multiple-boolean-operators/248112/6 "2020-09-17T18:24:44Z")

</div>

The EuiSearchBar does not offer a suggestions feature. If you are trying to recreate the Kibana search bar, then I think you need to use Kibana components to do so.

All the documentation for EuiSearchBar is here: [https://elastic.github.io/eui/#/forms/search-bar](https://elastic.github.io/eui/#/forms/search-bar)

---

<div class="post-metadata">

**Author:** ![praveer](https://avatars.discourse-cdn.com/v4/letter/p/41988e/32.png) [@praveer](https://discuss.elastic.co/u/praveer)\
**Post date:** [September 21, 2020, 7:33am UTC](https://discuss.elastic.co/t/problem-implementing-euisearchbar-cannot-create-queries-with-multiple-boolean-operators/248112/7 "2020-09-21T07:33:22Z")

</div>

Hi Wylie,

Could please let us know from where can we get all list of Kibana components with documentation.

---

<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:** [October 19, 2020, 7:33am UTC](https://discuss.elastic.co/t/problem-implementing-euisearchbar-cannot-create-queries-with-multiple-boolean-operators/248112/8 "2020-10-19T07:33:24Z")

</div>

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