# Query with and & or on 2 lists

**URL:** <https://discuss.elastic.co/t/query-with-and-or-on-2-lists/161462>\
**Category:** Elasticsearch\
**Created:** [December 19, 2018, 7:24am UTC](https://discuss.elastic.co/t/query-with-and-or-on-2-lists/161462 "2018-12-19T07:24:19Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Michael\_Mangeng](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/michael_mangeng/32/38967_2.png) [@Michael\_Mangeng](https://discuss.elastic.co/u/Michael_Mangeng)\
**Post date:** [December 19, 2018, 7:24am UTC](https://discuss.elastic.co/t/query-with-and-or-on-2-lists/161462/1 "2018-12-19T07:24:19Z")

</div>

Hi all,

i'm new to elasticsearch and i want to perform a specific query i cannot figure out how to design.  
My Document is the following:

```auto
"_source": {
	"path": [
		"d9977506-61e0-45bb-81db-c5bac79248c0",
		"0c3c36ae-1282-48be-a275-0fc89cb24ce2"
	],
	"vis": ["*"],
	"params": {
		"en.name": "My Test organization",
		"de.name": "Meine Test organisation"
	}
}

```

My desired query should return all documents where:  
1.) A search String is matched in all params  
**AND**  
2.) "vis"-Array contains an "\*" **OR**"path"-array contains at least 1 UUID of a list of given UUIDs

In Text: Return all documents which contain the users search string AND (are of public visibility OR at least one of the supplied UUIDs is in the path-array of the document).

My most recent attempt is:

```auto
{
    "query" : {
	"bool": {
		"must": {
		        "query_string" : {
		            "query" : "Test"
		        }
		},
		"filter":{
			"bool": {
	        		"should": [
	        			{ "term": { "vis": "*" } },
	        			{ "terms": { "path": ["d9977506-61e0-45bb-81db-c5bac79248c0"] } }
	        		],
   		        	"minimum_should_match": 1
    			}
        	}
	}
    }
}

```

...but this simply returns nothing.

Is maybe the asterisk in the field "vis" a problem ? Or the dashes in the UUIDs of the path field ?

Thanks for any help,

greetings,  
Michael

---

<div class="post-metadata">

**Author:** ![Michael\_Mangeng](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/michael_mangeng/32/38967_2.png) [@Michael\_Mangeng](https://discuss.elastic.co/u/Michael_Mangeng)\
**Post date:** [December 19, 2018, 8:21am UTC](https://discuss.elastic.co/t/query-with-and-or-on-2-lists/161462/2 "2018-12-19T08:21:27Z")

</div>

Ok i think i got it - i simply changed the mapping to be:

```auto
{
  "properties": {
    "path": {
      "type": "keyword"
    },
    "vis": {
      "type": "keyword"
    },
    "params": {
      "type": "object"
    },
    "tags": {
      "type": "keyword"
    }
  }
}

```

Now it seems to be working as expected.

---

<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:** [January 16, 2019, 8:21am UTC](https://discuss.elastic.co/t/query-with-and-or-on-2-lists/161462/3 "2019-01-16T08:21:39Z")

</div>

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