# Multiple query with wildcard

**URL:** <https://discuss.elastic.co/t/multiple-query-with-wildcard/205920>\
**Category:** Elasticsearch\
**Created:** [October 30, 2019, 5:05pm UTC](https://discuss.elastic.co/t/multiple-query-with-wildcard/205920 "2019-10-30T17:05:24Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![icirco](https://avatars.discourse-cdn.com/v4/letter/i/dec6dc/32.png) [@icirco](https://discuss.elastic.co/u/icirco)\
**Post date:** [October 30, 2019, 5:05pm UTC](https://discuss.elastic.co/t/multiple-query-with-wildcard/205920/1 "2019-10-30T17:05:24Z")

</div>

hello,  
How to query easily ? Is any tool to help to implement the query ?

I've success to query on a range time but I would like to add a condition on a message pattern...

How to do that ? I've tried something like this :

> ```
> {
> "query": {
> "bool" : {
> "filter": {
> "term" : {
> "message" : "*my string*"
> }
> },
> "must" : {
> "range" : {
> "@timestamp" : {
> "gte" : "now-10m",
> "lt" : "now"
> }
> }
> }
> }
> 
> ```
> 
> }  
> }

---

<div class="post-metadata">

**Author:** ![icirco](https://avatars.discourse-cdn.com/v4/letter/i/dec6dc/32.png) [@icirco](https://discuss.elastic.co/u/icirco)\
**Post date:** [November 8, 2019, 2:06pm UTC](https://discuss.elastic.co/t/multiple-query-with-wildcard/205920/2 "2019-11-08T14:06:11Z")

</div>

is any help to add condition in my query ?

---

<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:** [November 8, 2019, 3:31pm UTC](https://discuss.elastic.co/t/multiple-query-with-wildcard/205920/3 "2019-11-08T15:31:10Z")

</div>

First, prefix wildcards are a performance killer. I would refrain from using it. In the above example there is no wildcard needed.. you could just search for `my AND string` using a `match` query. Keep in mind that this works differently than SQL.

Also, you probably want to move the `range` part in the `filter` part of a boolean query and move the `match` query into the `must` part in order to apply scoring.

---

<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 6, 2019, 3:35pm UTC](https://discuss.elastic.co/t/multiple-query-with-wildcard/205920/4 "2019-12-06T15:35:16Z")

</div>

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