Query_string query with "something"2 creates a span query

Versions (relevant - OpenSearch/Dashboard/Server OS/Browser):
OpenSearch 2.11.0

Describe the issue:
The following query fails with this error:

	"query_string": {
		"query": "for \"1 copper pipe \"2",
		"default_field": "fulltext_text",
		"default_operator": "OR"
"root_cause": [
		"type": "illegal_state_exception",
		"reason": "field \"fulltext_text\" was indexed without position data; cannot run SpanTermQuery (term=1)"

Basically the “2” after the ending quote turns the query into a span query and it fails because we did not index position data in our field. I don’t see anything about this behavior in the documentation for query_string. Is this expected behavior?


I think that if your field doesn’t have position data, any query where you ask for a phrase will fail :frowning:

query_string is not a phrase or term query, it is a full text query. It seems like somehow the “2” turned a full text query into a term query.

I changed our code to escape the quotes in that query, but it still feels like undocumented behavior.

query_string will turn your quoted text into a phrase: https://opensearch.org/docs/latest/query-dsl/full-text/query-string/#proximity-queries

I know about that, but there is no tilde in my query.

Tilde is for fuzzy or for the slop of a phrase if you have quotes. Quotes are for phrases, like you’d use in Google.