Trouble with _msearch, Unexpected character (':' (code 58)):

I'm having some trouble getting a search to work. I started with a working
query against one index, here's the query that works with one index:

curl -s -v -XGET http://localhost:9200/persons/_search?pretty=true -d '
{"query": {"filtered": {
"query": {
"query_string": {
"fields":["_id", "firstName", "lastName"],
"query":"*"
}
}}}}
'

That query returns records, everything ok. Now I've changed the query to
use _msearch, here's the new query:

curl -s -v -XGET http://localhost:9200/_msearch?pretty=true -d '
{"index": "persons"}
{"query": {"filtered": {
"query": {
"query_string": {
"fields":["_id", "firstName", "lastName"],
"query":""
}
}}}}
{"index": "groups"}
{"query": {"filtered": {
"query": {
"query_string": {
"fields":["_id", "name", "description"],
"query":"
"
}
}}}}
'

That query generates the following error:

"error" : "Unexpected character (':' (code 58)): expected a valid value
(number, String, array, object, 'true', 'false' or 'null')\n at [Source:
[B@1e44e3e9; line: 1, column: 299]"

My elastic search version is 0.19.10.

Thanks for any help on determining why I'm getting this error.

--

The queries in multi search shouldn't contain new lines ('\n'). Try this:

curl -s -v -XGET http://localhost:9200/_msearch?pretty=true -d '{"index":
"persons"}
{"query": {"filtered": { "query": { "query_string": {"fields":["_id",
"firstName", "lastName"], "query":""}}}}}
{"index": "groups"}
{"query": {"filtered": {"query": {"query_string": {"fields":["_id", "name",
"description"], "query":"
"}}}}}
'

On Thursday, December 20, 2012 3:59:14 PM UTC-5, David Boon wrote:

I'm having some trouble getting a search to work. I started with a
working query against one index, here's the query that works with one index:

curl -s -v -XGET http://localhost:9200/persons/_search\?pretty\=true -d '
{"query": {"filtered": {
"query": {
"query_string": {
"fields":["_id", "firstName", "lastName"],
"query":"*"
}
}}}}
'

That query returns records, everything ok. Now I've changed the query to
use _msearch, here's the new query:

curl -s -v -XGET http://localhost:9200/_msearch?pretty=true -d '
{"index": "persons"}
{"query": {"filtered": {
"query": {
"query_string": {
"fields":["_id", "firstName", "lastName"],
"query":""
}
}}}}
{"index": "groups"}
{"query": {"filtered": {
"query": {
"query_string": {
"fields":["_id", "name", "description"],
"query":"
"
}
}}}}
'

That query generates the following error:

"error" : "Unexpected character (':' (code 58)): expected a valid value
(number, String, array, object, 'true', 'false' or 'null')\n at [Source:
[B@1e44e3e9; line: 1, column: 299]"

My Elasticsearch version is 0.19.10.

Thanks for any help on determining why I'm getting this error.

--

Thanks, I suppose that should have been more obvious to me since I grasped
the spacing around "index".

This works:
curl -s -v -XGET http://localhost:9200/_msearch?pretty=true -d '
{"index": "persons"}
{"query": {"filtered": {"query": { "query_string": { "fields":["_id",
"firstName", "lastName"], "query":"" } }}}}
{"index": "groups"}
{"query": {"filtered": { "query": { "query_string": { "fields":["_id",
"name", "description"], "query":"
" } }}}}
'

It seems like a weakness to rely on spacing to delineate anything at all,
especially in a structured document like json. Maybe it's not a big deal
if you're using a driver, maybe only a problem for the rest api.

Thanks again!

On Thursday, December 20, 2012 5:10:05 PM UTC-5, Igor Motov wrote:

The queries in multi search shouldn't contain new lines ('\n'). Try this:

curl -s -v -XGET http://localhost:9200/_msearch?pretty=true -d '{"index":
"persons"}
{"query": {"filtered": { "query": { "query_string": {"fields":["_id",
"firstName", "lastName"], "query":""}}}}}
{"index": "groups"}
{"query": {"filtered": {"query": {"query_string": {"fields":["_id",
"name", "description"], "query":"
"}}}}}
'

On Thursday, December 20, 2012 3:59:14 PM UTC-5, David Boon wrote:

I'm having some trouble getting a search to work. I started with a
working query against one index, here's the query that works with one index:

curl -s -v -XGET http://localhost:9200/persons/_search\?pretty\=true -d '
{"query": {"filtered": {
"query": {
"query_string": {
"fields":["_id", "firstName", "lastName"],
"query":"*"
}
}}}}
'

That query returns records, everything ok. Now I've changed the query to
use _msearch, here's the new query:

curl -s -v -XGET http://localhost:9200/_msearch?pretty=true -d '
{"index": "persons"}
{"query": {"filtered": {
"query": {
"query_string": {
"fields":["_id", "firstName", "lastName"],
"query":""
}
}}}}
{"index": "groups"}
{"query": {"filtered": {
"query": {
"query_string": {
"fields":["_id", "name", "description"],
"query":"
"
}
}}}}
'

That query generates the following error:

"error" : "Unexpected character (':' (code 58)): expected a valid
value (number, String, array, object, 'true', 'false' or 'null')\n at
[Source: [B@1e44e3e9; line: 1, column: 299]"

My Elasticsearch version is 0.19.10.

Thanks for any help on determining why I'm getting this error.

--

Yes, it's an optimization hack in a sense and it's used only in two places

  • bulk indexing and multi_search. When node receives the multi_search
    request, it parses the request on two levels: multi_search level and search
    level. On the multi_search level, elasticsearch is interested only in
    headers ({"index":....} parts), and on the search level - only in search
    requests. If everything was wrapped into a single json, the search requests
    would have to be parsed twice.

On Friday, December 21, 2012 10:18:06 AM UTC-5, David Boon wrote:

Thanks, I suppose that should have been more obvious to me since I grasped
the spacing around "index".

This works:
curl -s -v -XGET http://localhost:9200/_msearch?pretty=true -d '
{"index": "persons"}
{"query": {"filtered": {"query": { "query_string": { "fields":["_id",
"firstName", "lastName"], "query":"" } }}}}
{"index": "groups"}
{"query": {"filtered": { "query": { "query_string": { "fields":["_id",
"name", "description"], "query":"
" } }}}}
'

It seems like a weakness to rely on spacing to delineate anything at all,
especially in a structured document like json. Maybe it's not a big deal
if you're using a driver, maybe only a problem for the rest api.

Thanks again!

On Thursday, December 20, 2012 5:10:05 PM UTC-5, Igor Motov wrote:

The queries in multi search shouldn't contain new lines ('\n'). Try this:

curl -s -v -XGET http://localhost:9200/_msearch?pretty=true -d
'{"index": "persons"}
{"query": {"filtered": { "query": { "query_string": {"fields":["_id",
"firstName", "lastName"], "query":""}}}}}
{"index": "groups"}
{"query": {"filtered": {"query": {"query_string": {"fields":["_id",
"name", "description"], "query":"
"}}}}}
'

On Thursday, December 20, 2012 3:59:14 PM UTC-5, David Boon wrote:

I'm having some trouble getting a search to work. I started with a
working query against one index, here's the query that works with one index:

curl -s -v -XGET http://localhost:9200/persons/_search\?pretty\=true -d
'
{"query": {"filtered": {
"query": {
"query_string": {
"fields":["_id", "firstName", "lastName"],
"query":"*"
}
}}}}
'

That query returns records, everything ok. Now I've changed the query
to use _msearch, here's the new query:

curl -s -v -XGET http://localhost:9200/_msearch?pretty=true -d '
{"index": "persons"}
{"query": {"filtered": {
"query": {
"query_string": {
"fields":["_id", "firstName", "lastName"],
"query":""
}
}}}}
{"index": "groups"}
{"query": {"filtered": {
"query": {
"query_string": {
"fields":["_id", "name", "description"],
"query":"
"
}
}}}}
'

That query generates the following error:

"error" : "Unexpected character (':' (code 58)): expected a valid
value (number, String, array, object, 'true', 'false' or 'null')\n at
[Source: [B@1e44e3e9; line: 1, column: 299]"

My Elasticsearch version is 0.19.10.

Thanks for any help on determining why I'm getting this error.

--