[Solved] Illegal State - START_ARRAY


(Lee Gee) #1

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

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


(Mark Harwood) #2

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
}

(Lee Gee) #3

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.


(Mark Harwood) #4

Some bugs are just waiting for a suitably-sized audience :slight_smile:


(system) #5

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