If I send a simple query to Elastic using the following code construct, in the response back I obtain my expected results:
webaddress = "http://localhost:9200/" + index + "/_search?q='hello world'"
set xml = server.Createobject("MSXML2.ServerXMLHTTP")
xml.Open "GET", webaddress ,False
xml.setRequestHeader "Authorization", "Basic " & Base64Encode("elastic:elastic123")
xml.Send
Now if I want to send a much more complex query such that It's not practical or possibly even possible to place the query on a single 'q' parameter as above. i.e.
You will need to use "POST" in order to be able to send a JSON body to the _search endpoint; as far as I am aware, MSXML2.ServerXMLHTTP cannot send a request body with "GET". I'd also recommend setting
HI changing to POST and also changing my index such that all the properties were declared as lowercase has given me better results, however on return, my response object only has the first 10 records being returned. When I'm expecting more. Via Kibana the 10 returned match the first 10 in the Kibana results window.
Bear in mind that this is not an efficient way to deeply paginate a large dataset; for this, you may consider using the scroll API or search after API.
I have had some success using the scroll API. However the issue I now have is that there is nothing being returned that I can test when all data has been returned. I thought I could check the txt.hits.hits.length Property, but on the last page in the Kibana output window it shows as [] but back in classic asp it just says 'Empty' but it's not in an 'Empty' state that classic asp would recognise and it doesn't return the literal word 'Empty'. Calling the scoll API continues to send back a valid scroll_id, took still continues to have a number greater than 0, even though nothing is returned, I've basically got nothing to interpret to tell me when I've reached the end.
However the issue I now have is that there is nothing being returned that I can test when all data has been returned.
When no more documents are being returned, you've reached the end. You can calculate how many calls this will be ahead of time from the first call, by using the total in the response of the first response in conjunction with the size parameter that's used.
Ok, thank you....This seems to work directly via Kibana doing the Math. So I'll fo and try my Classic asp now, though it makes my script a bit more messy :).
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.