# Query\_string with "Or" Query? (v1.6)

**URL:** <https://discuss.elastic.co/t/query-string-with-or-query-v1-6/42620>\
**Category:** Elasticsearch\
**Created:** [February 24, 2016, 5:19pm UTC](https://discuss.elastic.co/t/query-string-with-or-query-v1-6/42620 "2016-02-24T17:19:06Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Aaron\_Troy](https://avatars.discourse-cdn.com/v4/letter/a/5e9695/32.png) [@Aaron\_Troy](https://discuss.elastic.co/u/Aaron_Troy)\
**Post date:** [February 24, 2016, 5:19pm UTC](https://discuss.elastic.co/t/query-string-with-or-query-v1-6/42620/1 "2016-02-24T17:19:06Z")

</div>

Let's say I have an index with 2 fields:

```
lastName:
	type: 'string'

emailAddresses:
	type: 'object'
	properties:
	  address:
	    type: 'string'

```

I want to return any record that either the lastName or any emailAddresses.address contain a given query\_string.

For instance, for a query\_string "est"..

This user would match:

```
{
    "lastName": "Best",
    "emailAddresses": [
    	{
    		"address": "none@none.com"
    	}
    ]
}

```

This user would match:

```
{
    "lastName": "Mark",
    "emailAddresses": [
    	{
    		"address": "none@test.com"
    	}
    ]
}

```

And this user would NOT match:

```
{
    "lastName": "Mark",
    "emailAddresses": [
    	{
    		"address": "none@none.com"
    	}
    ]
}

```

I have this working with a filtered query and or/regexp filters:

```
{
  "query": {
    "filtered": {
      "query": {
        "match_all": {}
      },
      "filter": {
        "or": [
          {
            "regexp": {
              "lastName": ".*est.*"
            }
          },
          {
            "regexp": {
              "emailAddresses.address": ".*est.*"
            }
          }
        ]
      }
    }
  }
}

```

I'd really prefer to NOT have to use regexp, but I haven't figured out a way to do it otherwise. Is there a way in version 1.6?

---

<div class="post-metadata">

**Author:** ![Ivan](https://avatars.discourse-cdn.com/v4/letter/i/df788c/32.png) [@Ivan](https://discuss.elastic.co/u/Ivan)\
**Post date:** [February 24, 2016, 6:13pm UTC](https://discuss.elastic.co/t/query-string-with-or-query-v1-6/42620/2 "2016-02-24T18:13:53Z")

</div>

ngrams would be more performant, but it comes at the price of increase  
index size.

You can perhaps simplify your query by using a multi\_match:  
[https://www.elastic.co/guide/en/elasticsearch/reference/1.6/query-dsl-multi-match-query.html](https://www.elastic.co/guide/en/elasticsearch/reference/1.6/query-dsl-multi-match-query.html)

Ivan

---

<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:** [July 5, 2017, 11:13pm UTC](https://discuss.elastic.co/t/query-string-with-or-query-v1-6/42620/3 "2017-07-05T23:13:53Z")

</div>


