<?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 How to apply date filter while fetching data from Elastic search using Rest Connector in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/How-to-apply-date-filter-while-fetching-data-from-Elastic-search/m-p/1678443#M727930</link>
    <description>&lt;P&gt;I am using custom pagination while fetching data from Rest Connector, My script works fine and fetches all the data but because of less RAM on the source I was asked to do incremental. Can some one help me on how to apply date filter to load data from last uploaded date. Below is my Script&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;Total_Table:&lt;/P&gt;&lt;P&gt;SQL SELECT&lt;/P&gt;&lt;P&gt;"took",&lt;BR /&gt;"timed_out",&lt;BR /&gt;"__KEY_root",&lt;/P&gt;&lt;P&gt;(SELECT&lt;BR /&gt;"total" AS "total_u0",&lt;BR /&gt;"max_score",&lt;BR /&gt;"__KEY_hits",&lt;BR /&gt;"__FK_hits"&lt;BR /&gt;&lt;BR /&gt;FROM "hits" PK "__KEY_hits" FK "__FK_hits")&lt;BR /&gt;FROM JSON (wrap on) "root" PK "__KEY_root";&lt;/P&gt;&lt;P&gt;Let total=Peek('total_u0',0,'Total_Table');&lt;/P&gt;&lt;P&gt;Drop Table Total_Table;&lt;/P&gt;&lt;P&gt;let current_scroll_id = '';&lt;/P&gt;&lt;P&gt;Let totalfetched = 0;&lt;/P&gt;&lt;P&gt;Let pageSize = 10000;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;do while totalfetched &amp;lt; total&lt;/P&gt;&lt;P&gt;RestConnectorMasterTable:&lt;BR /&gt;SQL SELECT&lt;BR /&gt;"took",&lt;BR /&gt;"timed_out",&lt;BR /&gt;"__KEY_root",&lt;BR /&gt;(SELECT&lt;BR /&gt;"total",&lt;BR /&gt;"successful",&lt;BR /&gt;"failed",&lt;BR /&gt;"__FK__shards"&lt;BR /&gt;FROM "_shards" FK "__FK__shards"),&lt;BR /&gt;(SELECT&lt;BR /&gt;"total" AS "total_u0",&lt;BR /&gt;"max_score",&lt;BR /&gt;"__KEY_hits",&lt;BR /&gt;"__FK_hits",&lt;BR /&gt;(SELECT&lt;BR /&gt;"_index",&lt;BR /&gt;"_type",&lt;BR /&gt;"_id",&lt;BR /&gt;"_score",&lt;BR /&gt;"__KEY_hits_u0",&lt;BR /&gt;"__FK_hits_u0",&lt;BR /&gt;(SELECT&lt;BR /&gt;"input",&lt;BR /&gt;"questionId",&lt;BR /&gt;"dataId",&lt;BR /&gt;"response",&lt;BR /&gt;"solved",&lt;BR /&gt;"id",&lt;BR /&gt;"sessionId",&lt;BR /&gt;"time",&lt;BR /&gt;"userId",&lt;BR /&gt;"version",&lt;BR /&gt;"__FK__source"&lt;BR /&gt;FROM "_source" FK "__FK__source")&lt;BR /&gt;FROM "hits" PK "__KEY_hits_u0" FK "__FK_hits_u0")&lt;BR /&gt;FROM "hits" PK "__KEY_hits" FK "__FK_hits")&lt;BR /&gt;FROM JSON (wrap on) "root" PK "__KEY_root"&lt;BR /&gt;WITH CONNECTION(Url "http:XYZsearch?scroll=25m&amp;amp;scroll_id=$(current_scroll_id)&amp;amp;size=$(pageSize)");&lt;BR /&gt;// Action required: change URL included in 'WITH CONNECTION' as needed to support pagination for the REST source.&lt;BR /&gt;// Please see the documentation for "Loading paged data."&lt;/P&gt;&lt;P&gt;Let current_scroll_id = Peek('_scroll_id');&lt;/P&gt;&lt;P&gt;hitsinThisIteration:&lt;/P&gt;&lt;P&gt;LOAD max([__KEY_hits_u0]) as 'hitscount'&lt;/P&gt;&lt;P&gt;RESIDENT RestConnectorMasterTable&lt;/P&gt;&lt;P&gt;WHERE NOT IsNull([__FK_hits_u0]);&lt;/P&gt;&lt;P&gt;let totalfetched = peek('hitscount');&lt;/P&gt;&lt;P&gt;drop Table hitsinThisIteration;&lt;/P&gt;&lt;P&gt;loop;&lt;/P&gt;&lt;P&gt;[source_]:&lt;BR /&gt;LOAD [input],&lt;BR /&gt;[questionId],&lt;BR /&gt;[dataId],&lt;BR /&gt;[response],&lt;BR /&gt;[solved],&lt;BR /&gt;[id],&lt;BR /&gt;[sessionId],&lt;BR /&gt;[time],&lt;BR /&gt;[userId],&lt;BR /&gt;[version],&lt;BR /&gt;[__FK__source] AS [__KEY_hits_u0]&lt;BR /&gt;RESIDENT RestConnectorMasterTable&lt;BR /&gt;WHERE NOT IsNull([__FK__source]);&lt;BR /&gt;&lt;BR /&gt;DROP TABLE RestConnectorMasterTable;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Tried below 2 methods but didn’t work&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&lt;/STRONG&gt;WITH CONNECTION(Url "&lt;A href="http://hkl20052873.hc.cloud.hk.hsbc:9200/ichat-instance/_search?scroll=25m&amp;amp;scroll_id=$(current_scroll_id)&amp;amp;size=$(pageSize)&amp;amp;time=$(time)" target="_blank" rel="noopener"&gt;http://XYZ&lt;/A&gt;&lt;A href="http://hkl20052873.hc.cloud.hk.hsbc:9200/ichat-instance/_search?scroll=25m&amp;amp;scroll_id=$(current_scroll_id)&amp;amp;size=$(pageSize)" target="_blank" rel="noopener"&gt;_search&lt;/A&gt;&lt;A href="http://hkl20052873.hc.cloud.hk.hsbc:9200/ichat-instance/_search?scroll=25m&amp;amp;scroll_id=$(current_scroll_id)&amp;amp;size=$(pageSize)&amp;amp;time=$(time)" target="_blank" rel="noopener"&gt;?scroll=25m&amp;amp;scroll_id=$(current_scroll_id)&amp;amp;size=$(pageSize) &lt;FONT color="#FF0000"&gt;&amp;amp;time=$(time)&lt;/FONT&gt;&lt;/A&gt;");&lt;/P&gt;&lt;P&gt;WITH CONNECTION(Url "&lt;A href="http://hkl20052873.hc.cloud.hk.hsbc:9200/ichat-instance/_search?scroll=25m&amp;amp;scroll_id=$(current_scroll_id)&amp;amp;size=$(pageSize)" target="_blank" rel="noopener"&gt;http://XYZ_search?scroll=25m&amp;amp;scroll_id=$(current_scroll_id)&amp;amp;size=$(pageSize)&lt;/A&gt;",&lt;FONT color="#FF0000"&gt;QUERY "time" "$(time)"&lt;/FONT&gt;);&lt;/P&gt;</description>
    <pubDate>Sat, 16 Nov 2024 01:12:32 GMT</pubDate>
    <dc:creator>hsbc_m_chandan</dc:creator>
    <dc:date>2024-11-16T01:12:32Z</dc:date>
    <item>
      <title>How to apply date filter while fetching data from Elastic search using Rest Connector</title>
      <link>https://community.qlik.com/t5/QlikView/How-to-apply-date-filter-while-fetching-data-from-Elastic-search/m-p/1678443#M727930</link>
      <description>&lt;P&gt;I am using custom pagination while fetching data from Rest Connector, My script works fine and fetches all the data but because of less RAM on the source I was asked to do incremental. Can some one help me on how to apply date filter to load data from last uploaded date. Below is my Script&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;Total_Table:&lt;/P&gt;&lt;P&gt;SQL SELECT&lt;/P&gt;&lt;P&gt;"took",&lt;BR /&gt;"timed_out",&lt;BR /&gt;"__KEY_root",&lt;/P&gt;&lt;P&gt;(SELECT&lt;BR /&gt;"total" AS "total_u0",&lt;BR /&gt;"max_score",&lt;BR /&gt;"__KEY_hits",&lt;BR /&gt;"__FK_hits"&lt;BR /&gt;&lt;BR /&gt;FROM "hits" PK "__KEY_hits" FK "__FK_hits")&lt;BR /&gt;FROM JSON (wrap on) "root" PK "__KEY_root";&lt;/P&gt;&lt;P&gt;Let total=Peek('total_u0',0,'Total_Table');&lt;/P&gt;&lt;P&gt;Drop Table Total_Table;&lt;/P&gt;&lt;P&gt;let current_scroll_id = '';&lt;/P&gt;&lt;P&gt;Let totalfetched = 0;&lt;/P&gt;&lt;P&gt;Let pageSize = 10000;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;do while totalfetched &amp;lt; total&lt;/P&gt;&lt;P&gt;RestConnectorMasterTable:&lt;BR /&gt;SQL SELECT&lt;BR /&gt;"took",&lt;BR /&gt;"timed_out",&lt;BR /&gt;"__KEY_root",&lt;BR /&gt;(SELECT&lt;BR /&gt;"total",&lt;BR /&gt;"successful",&lt;BR /&gt;"failed",&lt;BR /&gt;"__FK__shards"&lt;BR /&gt;FROM "_shards" FK "__FK__shards"),&lt;BR /&gt;(SELECT&lt;BR /&gt;"total" AS "total_u0",&lt;BR /&gt;"max_score",&lt;BR /&gt;"__KEY_hits",&lt;BR /&gt;"__FK_hits",&lt;BR /&gt;(SELECT&lt;BR /&gt;"_index",&lt;BR /&gt;"_type",&lt;BR /&gt;"_id",&lt;BR /&gt;"_score",&lt;BR /&gt;"__KEY_hits_u0",&lt;BR /&gt;"__FK_hits_u0",&lt;BR /&gt;(SELECT&lt;BR /&gt;"input",&lt;BR /&gt;"questionId",&lt;BR /&gt;"dataId",&lt;BR /&gt;"response",&lt;BR /&gt;"solved",&lt;BR /&gt;"id",&lt;BR /&gt;"sessionId",&lt;BR /&gt;"time",&lt;BR /&gt;"userId",&lt;BR /&gt;"version",&lt;BR /&gt;"__FK__source"&lt;BR /&gt;FROM "_source" FK "__FK__source")&lt;BR /&gt;FROM "hits" PK "__KEY_hits_u0" FK "__FK_hits_u0")&lt;BR /&gt;FROM "hits" PK "__KEY_hits" FK "__FK_hits")&lt;BR /&gt;FROM JSON (wrap on) "root" PK "__KEY_root"&lt;BR /&gt;WITH CONNECTION(Url "http:XYZsearch?scroll=25m&amp;amp;scroll_id=$(current_scroll_id)&amp;amp;size=$(pageSize)");&lt;BR /&gt;// Action required: change URL included in 'WITH CONNECTION' as needed to support pagination for the REST source.&lt;BR /&gt;// Please see the documentation for "Loading paged data."&lt;/P&gt;&lt;P&gt;Let current_scroll_id = Peek('_scroll_id');&lt;/P&gt;&lt;P&gt;hitsinThisIteration:&lt;/P&gt;&lt;P&gt;LOAD max([__KEY_hits_u0]) as 'hitscount'&lt;/P&gt;&lt;P&gt;RESIDENT RestConnectorMasterTable&lt;/P&gt;&lt;P&gt;WHERE NOT IsNull([__FK_hits_u0]);&lt;/P&gt;&lt;P&gt;let totalfetched = peek('hitscount');&lt;/P&gt;&lt;P&gt;drop Table hitsinThisIteration;&lt;/P&gt;&lt;P&gt;loop;&lt;/P&gt;&lt;P&gt;[source_]:&lt;BR /&gt;LOAD [input],&lt;BR /&gt;[questionId],&lt;BR /&gt;[dataId],&lt;BR /&gt;[response],&lt;BR /&gt;[solved],&lt;BR /&gt;[id],&lt;BR /&gt;[sessionId],&lt;BR /&gt;[time],&lt;BR /&gt;[userId],&lt;BR /&gt;[version],&lt;BR /&gt;[__FK__source] AS [__KEY_hits_u0]&lt;BR /&gt;RESIDENT RestConnectorMasterTable&lt;BR /&gt;WHERE NOT IsNull([__FK__source]);&lt;BR /&gt;&lt;BR /&gt;DROP TABLE RestConnectorMasterTable;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Tried below 2 methods but didn’t work&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&lt;/STRONG&gt;WITH CONNECTION(Url "&lt;A href="http://hkl20052873.hc.cloud.hk.hsbc:9200/ichat-instance/_search?scroll=25m&amp;amp;scroll_id=$(current_scroll_id)&amp;amp;size=$(pageSize)&amp;amp;time=$(time)" target="_blank" rel="noopener"&gt;http://XYZ&lt;/A&gt;&lt;A href="http://hkl20052873.hc.cloud.hk.hsbc:9200/ichat-instance/_search?scroll=25m&amp;amp;scroll_id=$(current_scroll_id)&amp;amp;size=$(pageSize)" target="_blank" rel="noopener"&gt;_search&lt;/A&gt;&lt;A href="http://hkl20052873.hc.cloud.hk.hsbc:9200/ichat-instance/_search?scroll=25m&amp;amp;scroll_id=$(current_scroll_id)&amp;amp;size=$(pageSize)&amp;amp;time=$(time)" target="_blank" rel="noopener"&gt;?scroll=25m&amp;amp;scroll_id=$(current_scroll_id)&amp;amp;size=$(pageSize) &lt;FONT color="#FF0000"&gt;&amp;amp;time=$(time)&lt;/FONT&gt;&lt;/A&gt;");&lt;/P&gt;&lt;P&gt;WITH CONNECTION(Url "&lt;A href="http://hkl20052873.hc.cloud.hk.hsbc:9200/ichat-instance/_search?scroll=25m&amp;amp;scroll_id=$(current_scroll_id)&amp;amp;size=$(pageSize)" target="_blank" rel="noopener"&gt;http://XYZ_search?scroll=25m&amp;amp;scroll_id=$(current_scroll_id)&amp;amp;size=$(pageSize)&lt;/A&gt;",&lt;FONT color="#FF0000"&gt;QUERY "time" "$(time)"&lt;/FONT&gt;);&lt;/P&gt;</description>
      <pubDate>Sat, 16 Nov 2024 01:12:32 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/How-to-apply-date-filter-while-fetching-data-from-Elastic-search/m-p/1678443#M727930</guid>
      <dc:creator>hsbc_m_chandan</dc:creator>
      <dc:date>2024-11-16T01:12:32Z</dc:date>
    </item>
  </channel>
</rss>

