<?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>question Re: Need to plug a variable into a elasticsearch query in Support Questions</title>
    <link>https://community.cloudera.com/t5/Support-Questions/Need-to-plug-a-variable-into-a-elasticsearch-query/m-p/372151#M241167</link>
    <description>&lt;P&gt;&lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/105411"&gt;@Phil_I_AM&lt;/a&gt;&amp;nbsp;Welcome to the Cloudera Community!&lt;BR /&gt;&lt;BR /&gt;To help you get the best possible solution, I have tagged our NiFi experts&amp;nbsp;&lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/80381"&gt;@SAMSAL&lt;/a&gt;&amp;nbsp;and&amp;nbsp;&lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/35454"&gt;@MattWho&lt;/a&gt;&amp;nbsp; who may be able to assist you further.&lt;BR /&gt;&lt;BR /&gt;Please keep us updated on your post, and we hope you find a satisfactory solution to your query.&lt;/P&gt;</description>
    <pubDate>Mon, 05 Jun 2023 21:26:55 GMT</pubDate>
    <dc:creator>DianaTorres</dc:creator>
    <dc:date>2023-06-05T21:26:55Z</dc:date>
    <item>
      <title>Need to plug a variable into a elasticsearch query</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Need-to-plug-a-variable-into-a-elasticsearch-query/m-p/372149#M241165</link>
      <description>&lt;P&gt;I am trying to roll my own search_after pagination query by saving the last sort values to a db and then retrieving them on the next time I run the query.&amp;nbsp; Thing is if there are no sort values from the db this means this is a new query and I skip the search_after clause in my query. If I do retrieve a set of sort values from the db then I need to plug them into the query. I am having trouble with the EL statement. This is what I have:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;{
	"query": {
		"bool": {
			"must": [
				{"term": {"key1": "value1"}}
			],
			"must_not": [
				{"exists": {"key2": "value2"}}
			],
			"filter": [
				{"range": {"@timestamp": {"lte": "now-1w"}}}
			]
		}			
	}
	${search_after:isEmpty():not():ifElse(', \"search_after\": "${search_after}"', '')},
	"sort": [
		{"@timestamp": "asc"},
		{"value3": "asc"}
	]
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;The ${search_after} variable defined as&amp;nbsp; '[ts int milliseconds, "a key value string"]'&amp;nbsp; Including the sq brackets.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The error I am receiving is:&lt;BR /&gt;Unknown key for a VALUE_STRING in search_after line 15 col 20 type parsing exception&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Does anyone know how to write the variable correctly?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 05 Jun 2023 20:17:54 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Need-to-plug-a-variable-into-a-elasticsearch-query/m-p/372149#M241165</guid>
      <dc:creator>Phil_I_AM</dc:creator>
      <dc:date>2023-06-05T20:17:54Z</dc:date>
    </item>
    <item>
      <title>Re: Need to plug a variable into a elasticsearch query</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Need-to-plug-a-variable-into-a-elasticsearch-query/m-p/372151#M241167</link>
      <description>&lt;P&gt;&lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/105411"&gt;@Phil_I_AM&lt;/a&gt;&amp;nbsp;Welcome to the Cloudera Community!&lt;BR /&gt;&lt;BR /&gt;To help you get the best possible solution, I have tagged our NiFi experts&amp;nbsp;&lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/80381"&gt;@SAMSAL&lt;/a&gt;&amp;nbsp;and&amp;nbsp;&lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/35454"&gt;@MattWho&lt;/a&gt;&amp;nbsp; who may be able to assist you further.&lt;BR /&gt;&lt;BR /&gt;Please keep us updated on your post, and we hope you find a satisfactory solution to your query.&lt;/P&gt;</description>
      <pubDate>Mon, 05 Jun 2023 21:26:55 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Need-to-plug-a-variable-into-a-elasticsearch-query/m-p/372151#M241167</guid>
      <dc:creator>DianaTorres</dc:creator>
      <dc:date>2023-06-05T21:26:55Z</dc:date>
    </item>
    <item>
      <title>Re: Need to plug a variable into a elasticsearch query</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Need-to-plug-a-variable-into-a-elasticsearch-query/m-p/372211#M241183</link>
      <description>&lt;P&gt;I solved my problem. The solution is to not wrap the variable with double quotes.&lt;/P&gt;&lt;LI-CODE lang="python"&gt;${search_after:isEmpty():not():ifElse(', \"search_after\": ${search_after}', '')},&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 06 Jun 2023 18:43:32 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Need-to-plug-a-variable-into-a-elasticsearch-query/m-p/372211#M241183</guid>
      <dc:creator>Phil_I_AM</dc:creator>
      <dc:date>2023-06-06T18:43:32Z</dc:date>
    </item>
  </channel>
</rss>

