<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Getting Data from Elastic Stack with REST with Scroll in Power Query</title>
    <link>https://community.fabric.microsoft.com/t5/Power-Query/Getting-Data-from-Elastic-Stack-with-REST-with-Scroll/m-p/2100691#M61925</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="115458" data-lia-user-login="nicpenning" class="lia-mention lia-mention-user"&gt;nicpenning&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Im new to ELK, how to get the api key value ?&lt;/P&gt;</description>
    <pubDate>Mon, 27 Sep 2021 15:25:47 GMT</pubDate>
    <dc:creator>Maggi029</dc:creator>
    <dc:date>2021-09-27T15:25:47Z</dc:date>
    <item>
      <title>Getting Data from Elastic Stack with REST with Scroll</title>
      <link>https://community.fabric.microsoft.com/t5/Power-Query/Getting-Data-from-Elastic-Stack-with-REST-with-Scroll/m-p/230222#M12230</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm pulling data into Power BI using the Elastic Stack REST API, but I'm running into a problem when trying to pull more than 10k records.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In order to do so, I need to use the scroll function:&amp;nbsp;&lt;A href="https://www.elastic.co/guide/en/elasticsearch/reference/master/search-request-scroll.html" target="_blank"&gt;https://www.elastic.co/guide/en/elasticsearch/reference/master/search-request-scroll.html&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The first call:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;GET /_search?scroll=1m&amp;nbsp;
{ "query": ...&amp;nbsp;}&lt;/PRE&gt;&lt;P&gt;Will return the first set of results plus a scroll id:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;SPAN class="str"&gt;DXF1ZXJ5QW5kRmV0Y2gBAAAAAAAAAD4...&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Which is used for subsequent calls:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;GET /_search {
&amp;nbsp; "scroll_id": "DXF1Z..."
}&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Each call returns a set of records plus a new scroll id. The scroll id is then passed onto the next record, and so on.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For performance reasons, I don't want to increase the number of records that can be returned by the REST API.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is it possible to solve this using Power BI?&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Thanks,&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Ken&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 11 Aug 2017 20:48:17 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Power-Query/Getting-Data-from-Elastic-Stack-with-REST-with-Scroll/m-p/230222#M12230</guid>
      <dc:creator>KenvM</dc:creator>
      <dc:date>2017-08-11T20:48:17Z</dc:date>
    </item>
    <item>
      <title>Re: Getting Data from Elastic Stack with REST with Scroll</title>
      <link>https://community.fabric.microsoft.com/t5/Power-Query/Getting-Data-from-Elastic-Stack-with-REST-with-Scroll/m-p/230250#M12234</link>
      <description>&lt;P&gt;There have been a few different threads like this but I believe the solution lies in creating a Power Query function that you call recursively. Here is an example of functions and recursion on a completely unrelated topic but might get you there:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.powerbi.com/t5/Community-Blog/Using-Recursion-to-Solve-Hex-to-Decimal-Conversion/ba-p/34153" target="_blank"&gt;https://community.powerbi.com/t5/Community-Blog/Using-Recursion-to-Solve-Hex-to-Decimal-Conversion/ba-p/34153&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 11 Aug 2017 23:25:32 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Power-Query/Getting-Data-from-Elastic-Stack-with-REST-with-Scroll/m-p/230250#M12234</guid>
      <dc:creator>Greg_Deckler</dc:creator>
      <dc:date>2017-08-11T23:25:32Z</dc:date>
    </item>
    <item>
      <title>Re: Getting Data from Elastic Stack with REST with Scroll</title>
      <link>https://community.fabric.microsoft.com/t5/Power-Query/Getting-Data-from-Elastic-Stack-with-REST-with-Scroll/m-p/232567#M12297</link>
      <description>&lt;P&gt;Thanks for pointing me in the right direction.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For anyone else that runs into this problem, here's the first iteration of a working function:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;let
    RecursiveElasticFetch = (queryUrl, scrollUrl, scrollId, counter) =&amp;gt;

    let
        Counter = if (counter = null) then 0 else counter,

        Results = if (scrollId = null) then            
            Json.Document(Web.Contents(queryUrl))
        else
            Json.Document(Web.Contents(scrollUrl&amp;amp;scrollId, [Headers=[MyHeader=Text.From(Counter)]])),

        ParsedResults = Table.FromList(Results[hits][hits], Splitter.SplitByNothing(), null, null, ExtraValues.Error),

        Return = if (Counter &amp;lt; 10) then
            ParsedResults &amp;amp; RecursiveElasticFetch(queryUrl, scrollUrl, Results[_scroll_id], Counter+1)
        else
            ParsedResults 
    in
        Return 
in
    RecursiveElasticFetch&lt;/PRE&gt;&lt;P&gt;For the parameters:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;queryUrl - The query URL that kicks off the search:&amp;nbsp;http://elasticsrch-dev:9200/intranet*/_search?scroll=1m&amp;amp;source={....}&lt;/P&gt;&lt;P&gt;scrollUrl - The URL used for subsequent searches (the scroll id is appended at the end):&amp;nbsp;http://elasticsrch-dev:9200/_search/scroll?scroll=1m&amp;amp;scroll_id=&lt;/P&gt;&lt;P&gt;scrollId - Used to pass the scroll_id to subsequent calls. Leave it blank for the first call&lt;/P&gt;&lt;P&gt;counter - Used to limit the number of iterations. Leave it blank for the first call.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 16 Aug 2017 15:51:03 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Power-Query/Getting-Data-from-Elastic-Stack-with-REST-with-Scroll/m-p/232567#M12297</guid>
      <dc:creator>KenvM</dc:creator>
      <dc:date>2017-08-16T15:51:03Z</dc:date>
    </item>
    <item>
      <title>Re: Getting Data from Elastic Stack with REST with Scroll</title>
      <link>https://community.fabric.microsoft.com/t5/Power-Query/Getting-Data-from-Elastic-Stack-with-REST-with-Scroll/m-p/322299#M14634</link>
      <description>&lt;P&gt;Hey&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="38905" data-lia-user-login="KenvM" class="lia-mention lia-mention-user"&gt;KenvM&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for sharing this iteration! Have you made any new changes? I'm&amp;nbsp;having an issue after the second loop of this script. First&amp;nbsp;call returns one set of records, second&amp;nbsp;call returns a new set, third and all subsequent calls returns a repeat set of data (not sure if from first or second call, but I could verify if needed).&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Have you encountered this yourself, and if so, have you found a solution?&lt;BR /&gt;&lt;BR /&gt;Link to a more detailed description on the Elastic forums here: &lt;A href="https://discuss.elastic.co/t/elasticsearch-record-aggregation-in-power-bi/111374" target="_self"&gt;Elastic Forums&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Tue, 12 Dec 2017 21:24:05 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Power-Query/Getting-Data-from-Elastic-Stack-with-REST-with-Scroll/m-p/322299#M14634</guid>
      <dc:creator>wendt_1</dc:creator>
      <dc:date>2017-12-12T21:24:05Z</dc:date>
    </item>
    <item>
      <title>Re: Getting Data from Elastic Stack with REST with Scroll</title>
      <link>https://community.fabric.microsoft.com/t5/Power-Query/Getting-Data-from-Elastic-Stack-with-REST-with-Scroll/m-p/322313#M14635</link>
      <description>&lt;P&gt;I looked at your example posted on the Elastic Search site, and I&amp;nbsp;think the problem may be in this section:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;        ## If function is called w/o a scrollID, then make the initial query, otherwise, query with a scrolling query
        Results = if (scrollID = null) then
            Json.Document(Web.Contents(url,[Content = Text.ToBinary(urlBody)]))
        else
            Json.Document(Web.Contents(scrollURL,[Content = Text.ToBinary(scrollBody&amp;amp;scrollID&amp;amp;scrollEND)])),&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I believe you need to pass the scrollId as part of the query on subsequent calls. Otherwise, you get a new request each time.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Try:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;        ## If function is called w/o a scrollID, then make the initial query, otherwise, query with a scrolling query
        Results = if (scrollID = null) then
            Json.Document(Web.Contents(url,[Content = Text.ToBinary(urlBody)]))
        else
            Json.Document(Web.Contents(scrollURL&lt;U&gt;&lt;STRONG&gt;&amp;amp;scrollId&lt;/STRONG&gt;&lt;/U&gt;,[Content = Text.ToBinary(scrollBody&amp;amp;scrollID&amp;amp;scrollEND)])),&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 12 Dec 2017 21:36:19 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Power-Query/Getting-Data-from-Elastic-Stack-with-REST-with-Scroll/m-p/322313#M14635</guid>
      <dc:creator>KenvM</dc:creator>
      <dc:date>2017-12-12T21:36:19Z</dc:date>
    </item>
    <item>
      <title>Re: Getting Data from Elastic Stack with REST with Scroll</title>
      <link>https://community.fabric.microsoft.com/t5/Power-Query/Getting-Data-from-Elastic-Stack-with-REST-with-Scroll/m-p/322847#M14644</link>
      <description>&lt;P&gt;Thanks for pointing that out! I actually am passing the scrollID with that calll, but I'm passing it as part of the body as opposed to the URL. Because the _scroll_id value passed back by Elasticsearch grows with the number of shards you have (if my understanding is correct), it can get crazy long. The one I'm returning is 13,873 characters long. Too long to send back as part of the URL. One forum post on that &lt;A href="http://elasticsearch-users.115913.n3.nabble.com/Ridiculously-long-Scroll-id-td4038567.html" target="_self"&gt;here&lt;/A&gt;.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The bolded part below is where I'm passing it.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;PRE&gt;        ## If function is called w/o a scrollID, then make the initial query, otherwise, query with a scrolling query
        Results = if (scrollID = null) then
            Json.Document(Web.Contents(url,[Content = Text.ToBinary(urlBody)]))
        else
            Json.Document(Web.Contents(scrollURL,&lt;STRONG&gt;[Content = Text.ToBinary(scrollBody&amp;amp;scrollID&amp;amp;scrollEND)]&lt;/STRONG&gt;)),&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 13 Dec 2017 13:37:19 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Power-Query/Getting-Data-from-Elastic-Stack-with-REST-with-Scroll/m-p/322847#M14644</guid>
      <dc:creator>wendt_1</dc:creator>
      <dc:date>2017-12-13T13:37:19Z</dc:date>
    </item>
    <item>
      <title>Re: Getting Data from Elastic Stack with REST with Scroll</title>
      <link>https://community.fabric.microsoft.com/t5/Power-Query/Getting-Data-from-Elastic-Stack-with-REST-with-Scroll/m-p/323219#M14659</link>
      <description>&lt;P&gt;Good to know, thanks!&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I replicated the problem in our environment and I believe I have a fix.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Power BI caches results from repeat calls to the same URL - this is why I added in the customer header. Adding the same snippet to your call seems to fix the problem for me.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Json.Document(Web.Contents(scrollURL,[Content = Text.ToBinary(scrollBody&amp;amp;scrollID&amp;amp;scrollEND), &lt;STRONG&gt;Headers=[MyHeader=Text.From(Counter)]&lt;/STRONG&gt;])),&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Let me know if this works for you.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 14 Dec 2017 01:53:51 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Power-Query/Getting-Data-from-Elastic-Stack-with-REST-with-Scroll/m-p/323219#M14659</guid>
      <dc:creator>KenvM</dc:creator>
      <dc:date>2017-12-14T01:53:51Z</dc:date>
    </item>
    <item>
      <title>Re: Getting Data from Elastic Stack with REST with Scroll</title>
      <link>https://community.fabric.microsoft.com/t5/Power-Query/Getting-Data-from-Elastic-Stack-with-REST-with-Scroll/m-p/323268#M14660</link>
      <description>&lt;P&gt;You. Are. A lifesaver. I had no idea that Power cached results, and your solution worked like a charm. Thank you for the time you put in to help me with this issue!&lt;/P&gt;</description>
      <pubDate>Thu, 14 Dec 2017 03:36:12 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Power-Query/Getting-Data-from-Elastic-Stack-with-REST-with-Scroll/m-p/323268#M14660</guid>
      <dc:creator>wendt_1</dc:creator>
      <dc:date>2017-12-14T03:36:12Z</dc:date>
    </item>
    <item>
      <title>Re: Getting Data from Elastic Stack with REST with Scroll</title>
      <link>https://community.fabric.microsoft.com/t5/Power-Query/Getting-Data-from-Elastic-Stack-with-REST-with-Scroll/m-p/512021#M19649</link>
      <description>&lt;P&gt;Hi Dear all, Im currently working with this function but I need to connect at ElasticSearch server using credentials (Basic username:password) , Do you know if this is possible?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I could not get a good result :(&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thanks a lot for your help.&lt;/P&gt;</description>
      <pubDate>Mon, 10 Sep 2018 15:25:36 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Power-Query/Getting-Data-from-Elastic-Stack-with-REST-with-Scroll/m-p/512021#M19649</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2018-09-10T15:25:36Z</dc:date>
    </item>
    <item>
      <title>Re: Getting Data from Elastic Stack with REST with Scroll</title>
      <link>https://community.fabric.microsoft.com/t5/Power-Query/Getting-Data-from-Elastic-Stack-with-REST-with-Scroll/m-p/512036#M19650</link>
      <description>&lt;P&gt;I haven't needed to do so yet.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I believe that the solutions on this page may help you though. They should how to pass headers through when making a web.contents call.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.powerbi.com/t5/Desktop/Issue-with-getting-data-via-API-with-bearer-token/td-p/126232" target="_self"&gt;https://community.powerbi.com/t5/Desktop/Issue-with-getting-data-via-API-with-bearer-token/td-p/126232&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 10 Sep 2018 15:38:24 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Power-Query/Getting-Data-from-Elastic-Stack-with-REST-with-Scroll/m-p/512036#M19650</guid>
      <dc:creator>KenvM</dc:creator>
      <dc:date>2018-09-10T15:38:24Z</dc:date>
    </item>
    <item>
      <title>Re: Getting Data from Elastic Stack with REST with Scroll</title>
      <link>https://community.fabric.microsoft.com/t5/Power-Query/Getting-Data-from-Elastic-Stack-with-REST-with-Scroll/m-p/512216#M19659</link>
      <description>&lt;P&gt;Thanks for you comment, I getting only a set of record not the whole dataset , Do you suggest me something?&lt;/P&gt;</description>
      <pubDate>Mon, 10 Sep 2018 20:55:26 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Power-Query/Getting-Data-from-Elastic-Stack-with-REST-with-Scroll/m-p/512216#M19659</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2018-09-10T20:55:26Z</dc:date>
    </item>
    <item>
      <title>Re: Getting Data from Elastic Stack with REST with Scroll</title>
      <link>https://community.fabric.microsoft.com/t5/Power-Query/Getting-Data-from-Elastic-Stack-with-REST-with-Scroll/m-p/638708#M22131</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I believe I am having the cached result issue. Adding this to the function ends up with an error since scrollBody and scrollEND are not defined anywhere in the code.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Where would I add these variables?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please help!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Nic&lt;/P&gt;</description>
      <pubDate>Wed, 06 Mar 2019 23:13:49 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Power-Query/Getting-Data-from-Elastic-Stack-with-REST-with-Scroll/m-p/638708#M22131</guid>
      <dc:creator>nicpenning</dc:creator>
      <dc:date>2019-03-06T23:13:49Z</dc:date>
    </item>
    <item>
      <title>Re: Getting Data from Elastic Stack with REST with Scroll</title>
      <link>https://community.fabric.microsoft.com/t5/Power-Query/Getting-Data-from-Elastic-Stack-with-REST-with-Scroll/m-p/638732#M22132</link>
      <description>&lt;P&gt;Just want to confirm: Are you using the code snippet that I posted in this forum or that wendt_1 posted in the Elastic forum?&lt;/P&gt;</description>
      <pubDate>Thu, 07 Mar 2019 01:23:17 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Power-Query/Getting-Data-from-Elastic-Stack-with-REST-with-Scroll/m-p/638732#M22132</guid>
      <dc:creator>KenvM</dc:creator>
      <dc:date>2019-03-07T01:23:17Z</dc:date>
    </item>
    <item>
      <title>Re: Getting Data from Elastic Stack with REST with Scroll</title>
      <link>https://community.fabric.microsoft.com/t5/Power-Query/Getting-Data-from-Elastic-Stack-with-REST-with-Scroll/m-p/638761#M22133</link>
      <description>Hi yes I used your code posted in this blog the problem is the data, I have millions of records and power bi crashes and it can not to finish to get all information. Imy thinking probably is the computer's hardware I mean ram , core etc.&lt;BR /&gt;&lt;BR /&gt;do you have another suggestion?&lt;BR /&gt;thanks</description>
      <pubDate>Thu, 07 Mar 2019 01:47:00 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Power-Query/Getting-Data-from-Elastic-Stack-with-REST-with-Scroll/m-p/638761#M22133</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2019-03-07T01:47:00Z</dc:date>
    </item>
    <item>
      <title>Re: Getting Data from Elastic Stack with REST with Scroll</title>
      <link>https://community.fabric.microsoft.com/t5/Power-Query/Getting-Data-from-Elastic-Stack-with-REST-with-Scroll/m-p/640592#M22170</link>
      <description>&lt;P&gt;Sorry emorquecho, that question was directed at nicpenning.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In your case, I'm not sure how to help or what the issue might be. Your suggestion sounds reasonable, but I haven't done a lot with Elastic data in Power BI since I originally posted on this.&lt;/P&gt;</description>
      <pubDate>Fri, 08 Mar 2019 16:07:43 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Power-Query/Getting-Data-from-Elastic-Stack-with-REST-with-Scroll/m-p/640592#M22170</guid>
      <dc:creator>KenvM</dc:creator>
      <dc:date>2019-03-08T16:07:43Z</dc:date>
    </item>
    <item>
      <title>Re: Getting Data from Elastic Stack with REST with Scroll</title>
      <link>https://community.fabric.microsoft.com/t5/Power-Query/Getting-Data-from-Elastic-Stack-with-REST-with-Scroll/m-p/650696#M22361</link>
      <description>&lt;P&gt;I didn't have the right code! I had a different code block I was using.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The following is the function I used that worked:&lt;/P&gt;&lt;PRE&gt;let
    RecursiveElasticFetch = (url, scrollURL, urlBody, scrollBody, scrollID, counter, scrollEND) =&amp;gt;

    let
        Counter = if (counter = null) then 0 else counter,
        Results = if (scrollID = null) then
            Json.Document(Web.Contents(url,[Content = Text.ToBinary(urlBody)]))
        else
            Json.Document(Web.Contents(scrollURL,[Content = Text.ToBinary(scrollBody&amp;amp;scrollID&amp;amp;scrollEND)])),
        ParsedResults = Table.FromList(Results[hits][hits], Splitter.SplitByNothing(), null, null, ExtraValues.Error),

        Return = if (Counter &amp;lt; 10) then
            ParsedResults &amp;amp; RecursiveElasticFetch(url, scrollURL, urlBody, scrollBody, Results[_scroll_id], Counter+1, scrollEND)
        else
            ParsedResults
    in
        Return
in
    RecursiveElasticFetch&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And this is a snippet of the query:&lt;/P&gt;&lt;PRE&gt;let
    url = "http://[elasticinstance]:9200/index*/_search?scroll=1m",
    scrollURL = "http://[elasticinstance]:9200/_search/scroll",
    urlBody = "{""size"":10000,""query"":{""match_all"":{}}}",
    scrollBody = "{""scroll"":""10m"",""scroll_id"":""",
    scrollID = null,
    counter = null,
    scrollEND = """}",
    Source = RecursiveElasticFetch(url, scrollURL, urlBody, scrollBody, scrollID, counter scrollEND)
in*
    Source*&lt;/PRE&gt;&lt;P&gt;* I chopped out all of my steps but I believe this should work.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I can query all the data, but it is a bit slow. It takes a few minutes for about 120K rows.&lt;/P&gt;</description>
      <pubDate>Thu, 02 May 2019 18:06:57 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Power-Query/Getting-Data-from-Elastic-Stack-with-REST-with-Scroll/m-p/650696#M22361</guid>
      <dc:creator>nicpenning</dc:creator>
      <dc:date>2019-05-02T18:06:57Z</dc:date>
    </item>
    <item>
      <title>Re: Getting Data from Elastic Stack with REST with Scroll</title>
      <link>https://community.fabric.microsoft.com/t5/Power-Query/Getting-Data-from-Elastic-Stack-with-REST-with-Scroll/m-p/668895#M22719</link>
      <description>&lt;P&gt;This might be a long shot, but would there be any reason why this query doesn't quite pull absolutely everything? I see that I am missing some of the most recent indexed data but I haven't figured how much yet. If anybody else is seeing this as well please let me know.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Also, is there a good method to only query anything newer than what has already been queried? It doesn't seem efficient to query everything every time there is a change in the data.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance!&lt;/P&gt;</description>
      <pubDate>Fri, 12 Apr 2019 16:16:01 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Power-Query/Getting-Data-from-Elastic-Stack-with-REST-with-Scroll/m-p/668895#M22719</guid>
      <dc:creator>nicpenning</dc:creator>
      <dc:date>2019-04-12T16:16:01Z</dc:date>
    </item>
    <item>
      <title>Re: Getting Data from Elastic Stack with REST with Scroll</title>
      <link>https://community.fabric.microsoft.com/t5/Power-Query/Getting-Data-from-Elastic-Stack-with-REST-with-Scroll/m-p/680065#M22968</link>
      <description>&lt;P&gt;I have the following code but for some reasons it's not working&lt;BR /&gt;can anyone help me correct it? i'm getting: Token comma expected error. and cant seem to solve it&lt;/P&gt;
&lt;PRE&gt;let
    url = "http://Redacted 'URL edited by Admin':82/the_hive*/_search?scroll=1m",
    scrollURL = "http://Redacted 'URL edited by Admin':82/_search/scroll",
    urlBody = "{""size"":10000,""query"":{""match_all"":{}}}",
    scrollBody = "{""scroll"":""10m"",""scroll_id"":""",
    scrollID = null,
    counter = null,
    scrollEND = """}",
    Source = RecursiveElasticFetch(url, scrollURL, urlBody, scrollBody, scrollID, counter, scrollEND)
    
    let
        RecursiveElasticFetch = (url, scrollURL, urlBody, scrollBody, scrollID, counter, scrollEND) =&amp;gt;

        let
            Counter = if (counter = null) then 0 else counter,
            Results = if (scrollID = null) then
                Json.Document(Web.Contents(url,[Content = Text.ToBinary(urlBody)]))
            else
                Json.Document(Web.Contents(scrollURL,[Content = Text.ToBinary(scrollBody&amp;amp;scrollID&amp;amp;scrollEND)])),
            ParsedResults = Table.FromList(Results[hits][hits], Splitter.SplitByNothing(), null, null, ExtraValues.Error),

            Return = if (Counter &amp;lt; 10) then
                ParsedResults &amp;amp; RecursiveElasticFetch(url, scrollURL, urlBody, scrollBody, Results[_scroll_id], Counter+1, scrollEND)
            else
                ParsedResults
        in
            Return
    in
        RecursiveElasticFetch
in
    Source&lt;/PRE&gt;
&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="115458" data-lia-user-login="nicpenning" class="lia-mention lia-mention-user"&gt;nicpenning&lt;/a&gt;&amp;nbsp; how do you actually combine the 2 queries to get the elastic scroll efect?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Reply edited by Admin&lt;/P&gt;</description>
      <pubDate>Fri, 12 Jun 2020 20:01:36 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Power-Query/Getting-Data-from-Elastic-Stack-with-REST-with-Scroll/m-p/680065#M22968</guid>
      <dc:creator>nahayo</dc:creator>
      <dc:date>2020-06-12T20:01:36Z</dc:date>
    </item>
    <item>
      <title>Re: Getting Data from Elastic Stack with REST with Scroll</title>
      <link>https://community.fabric.microsoft.com/t5/Power-Query/Getting-Data-from-Elastic-Stack-with-REST-with-Scroll/m-p/682774#M23031</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="131250" data-lia-user-login="nahayo" class="lia-mention lia-mention-user"&gt;nahayo&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Create your query with this code:&lt;/P&gt;&lt;PRE&gt;let
    url = "http://[elasticinstance]:9200/index*/_search?scroll=1m",
    scrollURL = "http://[elasticinstance]:9200/_search/scroll",
    urlBody = "{""size"":10000,""query"":{""match_all"":{}}}",
    scrollBody = "{""scroll"":""10m"",""scroll_id"":""",
    scrollID = null,
    counter = null,
    scrollEND = """}",
    Source = RecursiveElasticFetch(url, scrollURL, urlBody, scrollBody, scrollID, counter, scrollEND)
in
    Source&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You should create a function (Right-Click your Query and click new function) with this code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;let
    RecursiveElasticFetch = (url, scrollURL, urlBody, scrollBody, scrollID, counter, scrollEND) =&amp;gt;

    let
        Counter = if (counter = null) then 0 else counter,
        Results = if (scrollID = null) then
            Json.Document(Web.Contents(url,[Content = Text.ToBinary(urlBody)]))
        else
            Json.Document(Web.Contents(scrollURL,[Content = Text.ToBinary(scrollBody&amp;amp;scrollID&amp;amp;scrollEND)])),
        ParsedResults = Table.FromList(Results[hits][hits], Splitter.SplitByNothing(), null, null, ExtraValues.Error),

        Return = if (Counter &amp;lt; 10) then
            ParsedResults &amp;amp; RecursiveElasticFetch(url, scrollURL, urlBody, scrollBody, Results[_scroll_id], Counter+1, scrollEND)
        else
            ParsedResults
    in
        Return
in
    RecursiveElasticFetch&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 18 Jun 2020 22:46:43 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Power-Query/Getting-Data-from-Elastic-Stack-with-REST-with-Scroll/m-p/682774#M23031</guid>
      <dc:creator>nicpenning</dc:creator>
      <dc:date>2020-06-18T22:46:43Z</dc:date>
    </item>
    <item>
      <title>Re: Getting Data from Elastic Stack with REST with Scroll</title>
      <link>https://community.fabric.microsoft.com/t5/Power-Query/Getting-Data-from-Elastic-Stack-with-REST-with-Scroll/m-p/1156762#M37723</link>
      <description>&lt;P&gt;Revisiting this old post. This works well on an unauthenticated cluster.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Anyone know how to add an API Key to perform this type of query?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I understand I can add:&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;[Headers=[#"Authorization"="ApiKey redacted"]]&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;For web.content and use an anonymous login, but it doesn't seem to work when I do this:&lt;BR /&gt;&lt;BR /&gt;&lt;PRE&gt;let
    RecursiveElasticFetch = (url, scrollURL, urlBody, scrollBody, scrollID, counter, scrollEND) =&amp;gt;

    let
        Counter = if (counter = null) then 0 else counter,
        Results = if (scrollID = null) then
            Json.Document(Web.Contents(url,[Content = Text.ToBinary(urlBody),[Headers=[#"Authorization"="ApiKey redacted"]]]))
        else
            Json.Document(Web.Contents(scrollURL,[Content = Text.ToBinary(scrollBody&amp;amp;scrollID&amp;amp;scrollEND)])),
        ParsedResults = Table.FromList(Results[hits][hits], Splitter.SplitByNothing(), null, null, ExtraValues.Error),

        Return = if (Counter &amp;lt; 10) then
            ParsedResults &amp;amp; RecursiveElasticFetch(url, scrollURL, urlBody, scrollBody, Results[_scroll_id], Counter+1, scrollEND)
        else
            ParsedResults
    in
        Return
in
    RecursiveElasticFetch&lt;/PRE&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;This is the error I get.&lt;/DIV&gt;&lt;DIV&gt;&lt;BR /&gt;An error occurred in the ‘RecursiveElasticFetch’ query. DataSource.Error: Web.Contents failed to get contents from 'https://redacted:9200/index-*stats*/_search?scroll=1m' (406): Not Acceptable&lt;BR /&gt;Details:&lt;BR /&gt;DataSourceKind=Web&lt;BR /&gt;DataSourcePath=https://redacted:9200/filebeat-*stats*/_search&lt;BR /&gt;Url=https://redacted:9200/index-*stats*/_search?scroll=1m&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Any ideas how to authenticate with this scroll function / elastic query?&lt;/DIV&gt;</description>
      <pubDate>Fri, 12 Jun 2020 22:44:35 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Power-Query/Getting-Data-from-Elastic-Stack-with-REST-with-Scroll/m-p/1156762#M37723</guid>
      <dc:creator>nicpenning</dc:creator>
      <dc:date>2020-06-12T22:44:35Z</dc:date>
    </item>
  </channel>
</rss>

