This is along the line I was hoping for BUT..
[1] My queries are dynamically constructed (based on user input). My query is not a simple 'hello world' test against a particular field in a document. A typical query for me might look like:
{
"_source" : "talentId",
"from" : 0,
"size" : 10000,
"query" : {
"bool" : {
"must" : [
[
{
"terms" : {
"talentId" : [
"-1Nb66Le1Ag", "-3JBeHIE1Qg", "-4f8N7Ha1Ag",
"-46EAg6r1Ag", "-64epcYD1Qg", "-5m_tFVt1Ag",
"-5RLUpXc1Ag", "-6pNEKtC1Qg"]
]
}
}
],
{
"match_phrase" : {
"freeText" : "java"
}
}
]
}
}
}
All the stuff inside the query
node is dynamically constructed. In reality, the talentId
node might have 1M+ values (representing which documents I want to search for the match_phrase
.
Note also that I'm not asking for the documents found, but rather just the _source
.
[2] Through trial and error (and a lot of googles) I've got this much working:
var scroll = client.LowLevel.Search<StringResponse>(SearchIndex, queryText,
new SearchRequestParameters()
{
Scroll = TimeSpan.FromSeconds(10)
});
//-- parse the JSON string response into a in-memory representation
JsonObject jParsed = JsonParser.ParseString(scroll.Body).AsJsonObject;
//-- extract the scroll id
string scrollId = jParsed["_scroll_id"].AsString;
//-- request the data each scroll id holds
while (!string.IsNullOrEmpty(scrollId))
{
//-- get the scroll segments;
//!! MY expectation is that this will return the
// hits data and a continuation scroll
//!! BUT it fails with 400 error
===> var scroll2 = client.LowLevel.Scroll<StringResponse>(scrollId);
jParsed = JsonParser.ParseString(scroll2.Body).AsJsonObject;
//-- iterate through the results
//TODO
scrollId = jParsed["_scroll_id"].AsString;
}
I'm getting this error on trying to get the hits for each scroll id:
{
"error" : {
"root_cause" : [
{
"type" : "illegal_argument_exception",
"reason" : "Failed to parse request body"
}
],
"type" : "illegal_argument_exception",
"reason" : "Failed to parse request body",
"caused_by" : {
"type" : "json_parse_exception",
"reason" : "Unrecognized token 'DnF1ZXJ5VGhlbkZldGNoDwAAAAAMCNnFFnB4d2lOMDRBUnQ2RndEUUZCOHoyMlEAAAAADAjZxhZweHdpTjA0QVJ0NkZ3RFFGQjh6MjJRAAAAAAwImB8WemVGQU9LT3NSREdzWUJqU2dGcVdMZwAAAAAMCJgeFnplRkFPS09zUkRHc1lCalNnRnFXTGcAAAAADAiV7hZvNkIxMGxxalNZT0VZMlZITkZpQ2Z3AAAAAAwImCAWemVGQU9LT3NSREdz...': was expecting ('true', 'false' or 'null')\n at [Source: org.elasticsearch.common.bytes.BytesReference$MarkSupportingStreamInputWrapper@5f661aad; line: 1, column: 257]"
}
},
"status" : 400
}
So I presume the call is incorrect:
client.LowLevel.Scroll<StringResponse>(scrollId)
I've been struggling with this for days! (googling for examples has not helped :-()