Query with and & or on 2 lists

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:

"_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:

{
    "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

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

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

Now it seems to be working as expected.

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