# Elasticsearch “AND in query\_string” vs. “default\_operator AND”

**URL:** <https://discuss.elastic.co/t/elasticsearch-and-in-query-string-vs-default-operator-and/199578>\
**Category:** Elasticsearch\
**Created:** [September 16, 2019, 5:42am UTC](https://discuss.elastic.co/t/elasticsearch-and-in-query-string-vs-default-operator-and/199578 "2019-09-16T05:42:10Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![spotlight2001](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spotlight2001/32/54078_2.png) [@spotlight2001](https://discuss.elastic.co/u/spotlight2001)\
**Post date:** [September 16, 2019, 5:42am UTC](https://discuss.elastic.co/t/elasticsearch-and-in-query-string-vs-default-operator-and/199578/1 "2019-09-16T05:42:10Z")

</div>

elasticsearch v7.1.1

I dont understand the difference between a query\_string containing "AND" vs. "default\_operator AND"

I thought it should yield the same result, but doesnt:

Data:

```
HTTP POST http://localhost:9200/_bulk

{ "index" : { "_index" : "umlautsuche", "_id" : "1" } }
{"vorname": "Stephan-Jörg", "nachname": "Müller", "ort": "Hollabrunn"}

{ "index" : { "_index" : "umlautsuche", "_id" : "2" } }
{"vorname": "Stephan-Joerg", "nachname": "Mueller", "ort": "Hollabrunn"}

{ "index" : { "_index" : "umlautsuche", "_id" : "3" } }
{"vorname": "Stephan-Jörg", "nachname": "Müll", "ort": "Hollabrunn"}

```

No results here - unexpected by me:

```
HTTP POST http://localhost:9200/umlautsuche/_search

{
  "query": {
		"query_string": {
			"query": "Stefan Müller Jör*",
			"analyze_wildcard": true,
			"default_operator": "AND",
			"fields": ["vorname", "nachname"]
		}
	}
}

```

This query gives the results as expected by me:

```
HTTP POST http://localhost:9200/umlautsuche/_search

{
  "query": {
		"query_string": {
			"query": "Stefan AND Müller AND Jör*",
			"analyze_wildcard": true,
			"default_operator": "AND",
			"fields": ["vorname", "nachname"]
		}
	}
}

```

Index mapping:

```
HTTP POST http://localhost:9200/umlautsuche

{
  "settings": {
	"analysis": {
	  "char_filter": {
		"my_char_filter": {
		  "type": "mapping",
		  "mappings": ["ph => f"]
		}
	  },
	  "filter": {
		"my_ngram": {
			"type": "edge_ngram",
			"min_gram": 3,
			"max_gram": 10
		}
	  },
	  "analyzer": {
		"my_name_analyzer": {
		  "tokenizer": "standard",
		  "char_filter": [
			"my_char_filter"
		  ],
		  "filter": [
			"lowercase",
			"german_normalization"
		  ]
		}
	  }
	}
  },
  "mappings": {
	"date_detection": false,
	"dynamic_templates": [
	  {
		"string_fields_german": {
		  "match_mapping_type": "string",
		  "match": "*",
		  "mapping": {
			"type": "text",
			"analyzer": "my_name_analyzer"
		  }
		}
	  },
	  {
		"dates": {
		  "match": "lastModified",
		  "match_pattern": "regex",
		  "mapping": {
			"type": "date",
			"ignore_malformed": true
		  }
		}
	  }
	]
  }
}
```

---

<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 14, 2019, 5:42am UTC](https://discuss.elastic.co/t/elasticsearch-and-in-query-string-vs-default-operator-and/199578/2 "2019-10-14T05:42:29Z")

</div>

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