# \[Solved\] Illegal State - START\_ARRAY

**URL:** <https://discuss.elastic.co/t/solved-illegal-state-start-array/69420>\
**Category:** Elasticsearch\
**Created:** [December 19, 2016, 10:03am UTC](https://discuss.elastic.co/t/solved-illegal-state-start-array/69420 "2016-12-19T10:03:14Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Lee\_Gee](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/lee_gee/32/1217_2.png) [@Lee\_Gee](https://discuss.elastic.co/u/Lee_Gee)\
**Post date:** [December 19, 2016, 10:03am UTC](https://discuss.elastic.co/t/solved-illegal-state-start-array/69420/1 "2016-12-19T10:03:14Z")

</div>

Running the latest ES and Node.js client, the below query produces an error "illegal\_state\_exception", "Can't get text on a START\_ARRAY at 1:80", although the query seems to conform to the [docs](https://www.elastic.co/guide/en/elasticsearch/guide/current/bool-query.html):

[https://www.elastic.co/guide/en/elasticsearch/guide/current/bool-query.html](https://www.elastic.co/guide/en/elasticsearch/guide/current/bool-query.html)

```
{
    "query": {
        "bool": {
            "must": [
                {
                    "match": {
                        "type": "posting"
                    }
                },
                {
                    "match": {
                        "userid": "10158245646690355"
                    }
                }
            ],
            "should": [
                {
                    "match_phrase": {
                        "text": "xxx"
                    }
                },
                {
                    "match_phrase": {
                        "text": "xxxxxxxxxxxxx"
                    }
                }
            ]
        }
    },
    "highlight": {
        "fields": {
            "text": {
                "fragment_size": 150,
                "number_of_fragments": 3
            }
        }
    },
    "min_score": 0.95
}

console.js:8 [e[31mERRORe[39m] { Error: [illegal_state_exception] Can't get text on a START_ARRAY at 1:80
    at respond (/Users/lee/src/thingy/node_modules/elasticsearch/src/lib/transport.js:289:15)
    at checkRespForFailure (/Users/lee/src/thingy/node_modules/elasticsearch/src/lib/transport.js:248:7)
    at HttpConnector.<anonymous> (/Users/lee/src/thingy/node_modules/elasticsearch/src/lib/connectors/http.js:164:7)
    at IncomingMessage.wrapper (/Users/lee/src/thingy/node_modules/elasticsearch/node_modules/lodash/index.js:3095:19)
    at emitNone (events.js:91:20)
    at IncomingMessage.emit (events.js:185:7)
    at endReadableNT (_stream_readable.js:974:12)
    at _combinedTickCallback (internal/process/next_tick.js:74:11)
    at process._tickCallback (internal/process/next_tick.js:98:9)
status: 500,
displayName: 'InternalServerError',
message: '[illegal_state_exception] Can\'t get text on a START_ARRAY at 1:80',
path: '/postings/_search',
query: { size: 10000 },
body: 
{ error: 
    { root_cause: [Object],
        type: 'illegal_state_exception',
        reason: 'Can\'t get text on a START_ARRAY at 1:80' },
    status: 500 },
statusCode: 500,
response: '{"error":{"root_cause":[{"type":"illegal_state_exception","reason":"Can\'t get text on a START_ARRAY at 1:80"}],"type":"illegal_state_exception","reason":"Can\'t get text on a START_ARRAY at 1:80"},"status":500}',
toString: [Function],
toJSON: [Function] } ' at User.getStorage.search.then.catch in ../lib/view/User.js:74'

```

Saw this possibly-related issue: [https://github.com/elastic/elasticsearch/issues/15741](https://github.com/elastic/elasticsearch/issues/15741)

---

<div class="post-metadata">

**Author:** ![Mark\_Harwood](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mark_harwood/32/10538_2.png) [@Mark\_Harwood](https://discuss.elastic.co/u/Mark_Harwood)\
**Post date:** [December 19, 2016, 10:38am UTC](https://discuss.elastic.co/t/solved-illegal-state-start-array/69420/2 "2016-12-19T10:38:29Z")

</div>

Working for me on 5.0 GA release:

```
DELETE test
POST test/doc
{
	"type":"posting",
	"userid":10158245646690355,
	"text":"xx xxxxxxxxxxxxx"

}
GET test/doc/_search
{
	"query": {
		"bool": {
			"must": [
				{
					"match": {
						"type": "posting"
					}
				},
				{
					"match": {
						"userid": "10158245646690355"
					}
				}
			],
			"should": [
				{
					"match_phrase": {
						"text": "xxx"
					}
				},
				{
					"match_phrase": {
						"text": "xxxxxxxxxxxxx"
					}
				}
			]
		}
	},
	"highlight": {
		"fields": {
			"text": {
				"fragment_size": 150,
				"number_of_fragments": 3
			}
		}
	},
	"min_score": 0.95
}
```

---

<div class="post-metadata">

**Author:** ![Lee\_Gee](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/lee_gee/32/1217_2.png) [@Lee\_Gee](https://discuss.elastic.co/u/Lee_Gee)\
**Post date:** [December 19, 2016, 11:10am UTC](https://discuss.elastic.co/t/solved-illegal-state-start-array/69420/3 "2016-12-19T11:10:47Z")

</div>

Thank you for trying — it was my error: my JS was logging the wrong query: when I put a 'catch' clause in the right place, I saw I was passing an array where I ought to have been passing a string.

---

<div class="post-metadata">

**Author:** ![Mark\_Harwood](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mark_harwood/32/10538_2.png) [@Mark\_Harwood](https://discuss.elastic.co/u/Mark_Harwood)\
**Post date:** [December 19, 2016, 11:11am UTC](https://discuss.elastic.co/t/solved-illegal-state-start-array/69420/4 "2016-12-19T11:11:56Z")

</div>

Some bugs are just waiting for a suitably-sized audience 🙂

---

<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, 2017, 11:12am UTC](https://discuss.elastic.co/t/solved-illegal-state-start-array/69420/5 "2017-01-16T11:12:07Z")

</div>

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