Update by query by using jest client - elasticsearch

I am trying using script with query to update particular documents , but m not sure which class I need to use of jest client which work's with update by query
Here is my code
String h = " { "
+ " \"script\": { \n"
+ " \"inline\": \"ctx._source.order=params.prasad\", \n "
+ "\"params\": { \"prasad\":["+column+"] \n"
+ " } , \n"
+ "\"lang\": \"painless\" \n"
+ "},\n"
+ "\"query\": { \n"
+ "\"term\": { \n"
+ "\"orgid\": "+orgId+" \n"
+ "} \n"
+ "}";
LocalJestClientInstance.getInstance().getClient().execute(new Update.Builder(h).index(index).type(type).build());
This is not updating my documents.
Uri generating is this uri=loadfields/loadfields_type/_update,method=POST
Instead of _update how to get the _update_by_query

Jest didn't have it before but it looks like it does have it now.
My workaround was to use a second client as well, a standard http client and parse the JSON output just for this functionality that was missing.

Related

Generate Azure Storage SAS Signature In Ruby

I am trying to use the following code to generate a valid URL for accessing a blob in my Azure storage account. The Azure account name and key are stored in .env files. For some reason, the URL doesn't work; I get a Signature did not match error.
# version 2018-11-09 and later, https://learn.microsoft.com/en-us/rest/api/storageservices/create-service-sas#version-2018-11-09-and-later
signed_permissions = "r"
signed_start = "#{(start_time - 5.minutes).iso8601}"
signed_expiry = "#{(start_time + 10.minutes).iso8601}"
canonicalized_resource = "/blob/#{Config.azure_storage_account_name}/media/#{medium.tinyurl}"
signed_identifier = ""
signed_ip = ""
signed_protocol = "https"
signed_version = "2018-11-09"
signed_resource = "b"
signed_snapshottime = ""
rscc = ""
rscd = ""
rsce = ""
rscl = ""
rsct = ""
string_to_sign = signed_permissions + "\n" +
signed_start + "\n" +
signed_expiry + "\n" +
canonicalized_resource + "\n" +
signed_identifier + "\n" +
signed_ip + "\n" +
signed_protocol + "\n" +
signed_version + "\n" +
signed_resource + "\n" +
signed_snapshottime + "\n" +
rscc + "\n" +
rscd + "\n" +
rsce + "\n" +
rscl + "\n" +
rsct
sig = OpenSSL::HMAC.digest('sha256', Base64.strict_decode64(Config.azure_storage_account_key), string_to_sign.encode(Encoding::UTF_8))
sig = Base64.strict_encode64(sig)
#result = "#{medium.storageurl}?sp=#{signed_permissions}&st=#{signed_start}&se=#{signed_expiry}&spr=#{signed_protocol}&sv=#{signed_version}&sr=#{signed_resource}&sig=#{sig}"
PS: This is in Rails and medium is a record pulled from the DB that contains information about the blob in Azure.
Turns out the issue was clock skew. The signed_start and signed_expiry amounts I was using were too tight. WHen I relaxed then to -30/+20, I could reliably create SAS tokens using the snipper I posted.

Reading data from oracle using Flink

I'm trying to use Flink to work with Oracle. Just do a simple task copy data from table to a new one.
EnvironmentSettings settings = EnvironmentSettings.inStreamingMode();
TableEnvironment tEnv = TableEnvironment.create(settings);
tEnv.executeSql("CREATE TABLE ExistedTable(\n" +
" quoteid BIGINT,\n" +
" requestid BIGINT,\n" +
" createddt DATE,\n" +
" PRIMARY KEY (quoteid) NOT ENFORCED\n" +
") WITH (\n" +
" 'connector' = 'jdbc',\n" +
" 'url' = 'jdbc:oracle:thin:#xxx.xxx.xxx.xxx:1521:DBNAME',\n" +
" 'table-name' = 'TableName',\n" +
" 'driver' = 'oracle.jdbc.driver.OracleDriver',\n" +
" 'username' = 'UserName',\n" +
" 'password' = 'Password'\n" +
")");
tEnv.executeSql("CREATE TABLE NewTable (\n" +
" quoteid BIGINT,\n" +
" requestid BIGINT,\n" +
" createddt DATE,\n" +
" PRIMARY KEY (quoteid) NOT ENFORCED\n" +
") WITH (\n" +
" 'connector' = 'jdbc',\n" +
" 'url' = 'jdbc:oracle:thin:#xxx.xxx.xxx.xxx:1521:DBNAME',\n" +
" 'table-name' = 'NewTableName',\n" +
" 'driver' = 'oracle.jdbc.driver.OracleDriver',\n" +
" 'username' = 'UserName',\n" +
" 'password' = 'Password'\n" +
")");
Table data= tEnv.from("ExistedTable");
data.executeInsert("NewTable");
When running I've got error
The program finished with the following exception:
org.apache.flink.client.program.ProgramInvocationException: The main method caused an error: Unable to create a source for reading table 'default_catalog.default_database.xxx'.
Table options are:
'connector'='jdbc'
'driver'='oracle.jdbc.OracleDriver'
'password'='******'
'table-name'='xxx'
'url'='jdbc:oracle:thin:#xxx:1521:xxx'
'username'='xxx'
at org.apache.flink.client.program.PackagedProgram.callMainMethod(PackagedProgram.java:372)
at org.apache.flink.client.program.PackagedProgram.invokeInteractiveModeForExecution(PackagedProgram.java:222)
at org.apache.flink.client.ClientUtils.executeProgram(ClientUtils.java:114)
at org.apache.flink.client.cli.CliFrontend.executeProgram(CliFrontend.java:812)
at org.apache.flink.client.cli.CliFrontend.run(CliFrontend.java:246)
at org.apache.flink.client.cli.CliFrontend.parseAndRun(CliFrontend.java:1054)
at org.apache.flink.client.cli.CliFrontend.lambda$main$10(CliFrontend.java:1132)
at org.apache.flink.runtime.security.contexts.NoOpSecurityContext.runSecured(NoOpSecurityContext.java:28)
at org.apache.flink.client.cli.CliFrontend.main(CliFrontend.java:1132)
Caused by: org.apache.flink.table.api.ValidationException: Unable to create a source for reading table 'default_catalog.default_database.xxx'.
Is there any error in my sqlconnection. I couldn't found any example for working with oracle.
Thanks,
Which version of Flink are you using? Support for Oracle JDBC is available since Flink 1.15, which hasn't been released yet.

Sending very long strings from MetaTrader 4 to Python backend using ZeroMQ Push/Pull Pattern

I have a quite weird issue related to ZeroMQ messaging between MetaTrader 4 and a python backend.
The below shown code creates three strings which should be forwarded to a ZeroMQ PUSH socket. However, it only sends the live_trades string via the socket. Both the account_info and the historical_trades strings are not sent.
While debugging the weirdness only increased:
When I print the historical_trades string, it is shown in the MT4 expert journal, but not in the MT4 log editor
When I add Print( historical_trades ) before or after the pushSocket.send(StringFormat("%s", historical_trades, true)); it sends the string.
Possible issues which I actually exclude:
The PUSH socket is too slow: I decreased the timer to 10 seconds and more, same result
MT4 itself is too slow to create the strings: It prints them correctly, so it is fast enough
The ZeroMQ SNDHWM ( HighWaterMark ) blocks the EA/socket from sending multiple strings in no time: Already increased it to 100 which should be more than sufficient
Any other ideas I cannot verify with debugging:
The MT4 Print() function does some other stuff behind the scenes which enables the EA to send the string?
Maybe there is a maximum string size in MT4 which blocks the string creation loop (my string is around 35.000 characters long). But then why does it work when I just Print() the string once within the onTimer() function?...
Any chance that the account related information is not accessible on weekends?
Or it is just my code which might be buggy..
Any ideas much appreciated!
int OnInit()
{
//---
EventSetTimer(2); // Set Second Timer as push intervall
context.setBlocky(false);
// Send data to PULL_PORT that consumer is listening to.
Print("Connecting MT4 Dashex Feeder to Dashboard on Port " + IntegerToString(PUSH_PORT) + "..");
pushSocket.connect(StringFormat("%s://%s:%d", ZEROMQ_PROTOCOL, HOSTNAME, PUSH_PORT));
pushSocket.setSendHighWaterMark(100);
pushSocket.setLinger(0);
//---
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Expert deinitialization function |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
//---
Print("Disconnecting MT4 Dashex Feeder on Port " + IntegerToString(PUSH_PORT) + "..");
pushSocket.disconnect(StringFormat("%s://%s:%d", ZEROMQ_PROTOCOL, HOSTNAME, PUSH_PORT));
// Shutdown ZeroMQ Context
context.shutdown();
context.destroy(0);
EventKillTimer();
}
//---
//+------------------------------------------------------------------+
//| Expert timer function |
//+------------------------------------------------------------------+
void OnTimer()
{
/*
1.) Account information
*/
string account_info = "";
account_info = account_info +
"account_info|" +
version + "|" +
DID + "|" +
IntegerToString(AccountNumber()) + "|" +
AccountInfoString(ACCOUNT_COMPANY) + "|" +
IntegerToString(AccountInfoInteger(ACCOUNT_LEVERAGE)) + "|" +
DoubleToString(AccountInfoDouble(ACCOUNT_BALANCE),2) + "|" +
DoubleToString(AccountInfoDouble(ACCOUNT_PROFIT),2) + "|" +
DoubleToString(AccountInfoDouble(ACCOUNT_EQUITY),2) + "|" +
DoubleToString(AccountInfoDouble(ACCOUNT_MARGIN),2) + "|" +
DoubleToString(AccountInfoDouble(ACCOUNT_MARGIN_FREE),2) + "|" +
DoubleToString(AccountInfoDouble(ACCOUNT_MARGIN_LEVEL),2) + "|" +
AccountInfoString(ACCOUNT_CURRENCY) + "|" +
IntegerToString(IsDemo()) + "|" +
pushSocket.send(StringFormat("%s", account_info, true));
Print("Pushing Account Information To Dashex.Finance Dashboard For Account No. " + IntegerToString(AccountNumber()));
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
/*
2.) Pending and running trades
*/
int live_orders = OrdersTotal();
string live_trades = "";
for(int i=live_orders; i >= 0; i--)
{
if(OrderSelect(i,SELECT_BY_POS)==false) continue;
live_trades = live_trades +
"live_trades|" +
version + "|" +
DID + "|" +
IntegerToString(AccountNumber()) + "|" +
IntegerToString(OrderTicket()) + "|" +
TimeToString(OrderOpenTime(), TIME_DATE|TIME_SECONDS) + "|" +
TimeToString(OrderCloseTime(), TIME_DATE|TIME_SECONDS) + "|" +
IntegerToString(OrderType()) + "|" +
DoubleToString(OrderLots(),2) + "|" +
OrderSymbol() + "|" +
DoubleToString(OrderOpenPrice(),5) + "|" +
DoubleToString(OrderClosePrice(),5) + "|" +
DoubleToString(OrderStopLoss(),5) + "|" +
DoubleToString(OrderTakeProfit(),5) + "|" +
DoubleToString(OrderCommission(),2) + "|" +
DoubleToString(OrderSwap(),2) + "|" +
DoubleToString(OrderProfit(),2) + "|" +
"<" + OrderComment() + ">|";
}
pushSocket.send(StringFormat("%s", live_trades, true));
Print("Pushing Live Trades To Dashex.Finance Dashboard For Account No. " + IntegerToString(AccountNumber()));
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
/*
3.) History Trades
*/
int hstTotal = OrdersHistoryTotal();
string historical_trades = "";
Print(hstTotal);
for(int i=hstTotal; i >= 0; i--)
{
if(OrderSelect(i,SELECT_BY_POS,MODE_HISTORY)==false) continue;
historical_trades = historical_trades +
"historical_trades|" +
version + "|" +
DID + "|" +
IntegerToString(AccountNumber()) + "|" +
IntegerToString(OrderTicket()) + "|" +
TimeToString(OrderOpenTime(), TIME_DATE|TIME_SECONDS) + "|" +
TimeToString(OrderCloseTime(), TIME_DATE|TIME_SECONDS) + "|" +
IntegerToString(OrderType()) + "|" +
DoubleToString(OrderLots(),2) + "|" +
OrderSymbol() + "|" +
DoubleToString(OrderOpenPrice(),5) + "|" +
DoubleToString(OrderClosePrice(),5) + "|" +
DoubleToString(OrderStopLoss(),5) + "|" +
DoubleToString(OrderTakeProfit(),5) + "|" +
DoubleToString(OrderCommission(),2) + "|" +
DoubleToString(OrderSwap(),2) + "|" +
DoubleToString(OrderProfit(),2) + "|" +
"<" + OrderComment() + ">|";
}
pushSocket.send(StringFormat("%s", historical_trades, true));
Print("Pushing History Trades To Dashex.Finance Dashboard For Account No. " + IntegerToString(AccountNumber()));
Sleep(1);
}
MetaTrader 4 log.editor:
MetaTrader 4 console:
Q : Any chance that the account related information is not accessible on weekends?
This has an easy proof: do a Comment( aStringUnderTEST ); + check all account / Broker-related items.
Q : Maybe there is a maximum string size in MT4 which blocks the string creation loop...?
This is, except a case of an MT4-Build-X.Y.Z release-bug awaiting a BugFIX, very low probability hypothesis.
Yet it has an easy proof: do a loop of growing string-lengths and test until what size the processing keeps working. The indirectly proved size-limit will help you track the root cause, MT4 not being the SPoF here, is it?
Q : The MT4 Print function does some other stuff behind the scenes which enables the EA to send the string?
The MT4 Support ought be contacted if this is to get confirmed or denied. The software is licensed as an as-is product, so do not expect any rapid response or a rocket science to take place if you try to drill down to the bolts and nuts, inside their closed and sealed product.

strange behaviour when xcode evaluates variables at runtime

I get the error "expression was too complex to be solved in reasonable time" for the following code.
I saw other threads regarding the error with much complexer expressions then mine and it was stated, that the compiler is buggy.
Is this also true for the following simple code ?
Problem:
let value1:Int = 1;
let value2:Int = 3;
var sql="The Number 2 is in "
+ " between " + String(iFrom) + " and " + String(iTo) + ".";
but this works
let value1:Int = 1;
let value2:Int = 3;
var sql="The Number 2 is in "
+ " between " + String(iFrom) + " and " + String(iTo);
The difference is only the "." at the end of concatenation.
If its a bug:
The process SourceKitService is running at max and slowes everything down. Can compilation at runtime be disabled ?
One thing you could try that I've had some success with is to try specifically typing your sql variable.
var sql: String ="The Number 2 is in "
+ " between " + String(iFrom) + " and " + String(iTo) + ".";

How to display fields in new line in same textBox in telerik reporting?

I am using Silverlight4 and Telerik Reporting Q3 2011. I am trying to Generate Reports of all Outlets. I used Table to display its fields. And I want to Display Full Address in same cell. How could I?
I Used following Experession to display Full Address in same cell.
= Fields.AddressLine1
+ ", " + Fields.AddressLine2
+ ", " + Fields.Suburb
+ ", " + Fields.City
+ ", " + Fields.State
+ ", " + Fields.Country
I want do display this in same cell but want output like below..
=====================
Address
=====================
15A,
xxxx xxxRoad,
xxxxxx,
xxxxxxxx
====================
But I m getting this
=====================
Address
=====================
15A, xxxx xxxRoad, xxxxxx, xxxxxxxx
=====================
How do I get Output Which I want?
made the Function NewLineFeeds() in this function I used Replace() Method to replace the specific string to newLine(\n) .
public static string NewLineFeeds(string text)
{
string result = text.Replace(", ", "\n");
result = result.Replace(", ", "\n");
result = result.Replace(", ", "\n");
return result;
}
and my Expression is
=NewLineFeeds(Fields.AddressLine1
+ ", " + Fields.AddressLine2
+ ", " + Fields.Suburb
+ ", " + Fields.City
+ ", " + Fields.State
+ ", " + Fields.Country)
This call the Function NewLineFeeds() and replace ", " to \n (new Line). Add this will work Fine..

Resources