Can someone post example for percentile in solr - solrj

The refernces I see are in the form of HTTP request. But how is it in code example?
Maybe this syntax:
search.setParam("facet", true);
search.setParam("percentiles", true);
search.setParam("percentiles.field", "networkTime");
search.setParam("percentiles.requested.percentiles", "25,50,75");
search.setParam("percentiles.lower.fence", "0");
search.setParam("percentiles.upper.fence", "1000000");
search.setParam("percentiles.gap", "10");
search.setParam("percentiles.averages", true);
Or this syntax?
search.setParam("facet", true);
search.setParam("facets.stats.percentiles", true);
search.setParam("facets.stats.percentiles.field", "networkTime");
search.setParam("f.networkTime.stats.percentiles.requested", "25,50,75");
search.setParam("f.networkTime.stats.percentiles.lower.fence", "0");
search.setParam("f.networkTime.stats.percentiles.upper.fence", "1000000");
search.setParam("f.networkTime.stats.percentiles.gap", "10");
search.setParam("facets.stats.percentiles.averages", true);
Thanks!

Related

List to form-encoded parameters in Casablanca

I am using cpprestsdk (casabalanca) to POST a request to a server
and I have a list of parameters
std::list<std::pair<string, string>> query;
query.push_back(std::make_pair("val1", "one two"));
query.push_back(std::make_pair("val2", "yo"));
that needs to be encoded as form-encoded parameters.
val1=one%20two&val2=yo
The problem I cannot find a Api to do that (like I have web::json::value for a json payload).
I need to encode each key/value and do the concatenation myself.
There is an Api I am missing out or this simply doesn't exist ?
Found the solution...
web::http::http_request request;
web::uri_builder parameter;
parameter.append_query("val1", "one two", true);
parameter.append_query("val2", "yo", true);
request.set_body(parameter.query(), web::http::details::mime_types::application_x_www_form_urlencoded);
You can use the std::list and fill query parameter
std::string test_url("http://127.0.0.1:9044/api/v1/somepath/");
web::uri_builder ub(test_url);
std::list<std::pair<std::string, std::string>> query;
query.push_back(std::make_pair("val1", "one two"));
query.push_back(std::make_pair("val2", "yo"));
for(auto const &it: query)
{
std::cout<<it.first<<" : "<<it.second<<std::endl;
ub.append_query(it.first, it.second);
}
std::string uri_builder_str = ub.to_string();
http_client client(uri_builder_str);
std::cout<<uri_builder_str<<std::endl;
return client.request(methods::GET);

OnvifClientPTZ onvif c++ unable to get configuration options

tt__Profile *t = profiles.Profiles.at(0);
OnvifClientPTZ PTZ(onvifDevice);
_tptz__GetConfigurationOptions tptz__GetConfigurationOptions;
_tptz__GetConfigurationOptionsResponse tptz__GetConfigurationOptionsResponse;
tt__PTZConfigurationOptions *options;
int response = PTZ.GetConfigurationOptions(tptz__GetConfigurationOptionsResponse, t->token);
Problem is that PTZ#GetConfigurationOptions returns value of 1 (#response).
Object #onvifDevice seems to be fine (onvifDevice.hasPTZ returns true).
I've tried debugging and onvifDevice.GetPTZUrl(strUrl) returns true and sets strUrl to 192.168.1.88:2000/device/services which is soap_endpoint of PtzProxy object (ptzProxy.soap_endpoint = strUrl.c_str();) and it seems to be fine. Also soap_action is "www.onvif.org/ver20/ptz/wsdl/GetConfigurationOptions" which also seems to be fine.
I'm using https://github.com/xsmart/onvifcpplib.
In PTZ proxy returns here:
tptz__GetConfigurationOptionsResponse->soap_get(soap, "tptz:GetConfigurationOptionsResponse", "");
if (soap->error)
return soap_recv_fault(soap, 0);
Any help would be appreciated.
I've found the solution. Problem was in this line:
int response = PTZ.GetConfigurationOptions(tptz__GetConfigurationOptionsResponse, t->token);
OnvifPTZClient#GetConfigurationOptions requests PTZConfiguration token, not profile token. So correct line would be:
response = PTZ.GetConfigurationOptions(tptz__GetConfigurationOptionsResponse, tr->PTZConfiguration->token);

Pocketsphinx returns empty string for hypothesis

I'm using pocketshpinx for speech recognition in a custom C++ application. I noticed that sometimes the hypothesis string returned by the ps_get_hyp() method is an empty string.
Question: Is this an expected behaviour? If so, is there a way to tell pocketsphinx to not give the empty string as a hypothesis?
Following is a snippet of the relevant portion of my code:
do { ReadAudioBuffer(); } while (!in_speech);
while (in_speech) { ReadAudioBuffer(); }
ps_end_utt(ps);
hyp = ps_get_hyp(ps, NULL);
The ReadAudioBuffer() method:
void SpeechRecognizer::ReadAudioBuffer()
{
if ((k = ad_read(ad, adbuf, 2048)) < 0)
{
UE_LOG(LogTemp, Warning, TEXT("Failed to read audio\n"));
return;
}
ps_process_raw(ps, adbuf, k, FALSE, FALSE);
in_speech = ps_get_in_speech(ps);
FPlatformProcess::Sleep(0.005);
}
Question: Is this an expected behaviour?
There is nothing wrong with it
If so, is there a way to tell pocketsphinx to not give the empty string as a hypothesis?
If you said nothing what should be returned then?
FPlatformProcess::Sleep(0.005);
Sleep is not really needed here

C++ ExportAsFixedFormat to save as PDF

I'm using VS2010 C++ and Office 2010 to create reports based on Excel templates. C++ can successfully open, insert values & save the xlsx as something else but I'd like it to also save it as PDF. I'm struggling with the _variant_t parameters of the ExportAsFixedFormat() function despite seeing examples in VB, C# and PowerShell. Can anybody provide example code?
The shell of my functionality:
Excel::_ApplicationPtr pXL;
if (FAILED(pXL.CreateInstance("Excel.Application")))
{
return FALSE;
}
pXL->Workbooks->Open("c:\\tempRep.xlsx");
pXL->PutVisible(0, FALSE);
// Get the active worksheet
Excel::_WorksheetPtr pWksheet = pXL->ActiveSheet;
//... use the spreadsheet
// Save the worksheet
pWksheet->SaveAs("c:\\newRep.xlsx");
pWksheet->ExportAsFixedFormat(??const _variant_t &Filename, ....??)
Thanks, Steve
Try using the SetString method:
_variant_t Filename;
Filename.SetString("c:\\temp\\myfile.txt");
pWksheet->ExportAsFixedFormat(Filename, ....)
From Microsoft 's document, it is 0 or 1 and works for me.
https://msdn.microsoft.com/en-us/library/bb241296(v=office.12).aspx
VARIANT vtMissing; // VARIANT defining a missing/optional parameter.
vtMissing.vt = VT_ERROR;
vtMissing.scode = DISP_E_PARAMNOTFOUND;
book.ExportAsFixedFormat(0, COleVariant(TEXT("myExportPDF.pdf")), vtMissing,
vtMissing, vtMissing, vtMissing, vtMissing, vtMissing, vtMissing);

Example code of FBML App that uses signed_request?

We did not know that Oct 1 is also deadline for signed_request.
Does anyone have example code to do signed_request for FBML apps?
We are trying to beat the deadline on Oct 1. Thanks!
The signed_request documentation shows how to do it in PHP. It's pretty easy to do in any language.
function parse_signed_request($signed_request, $secret) {
list($encoded_sig, $payload) = explode('.', $signed_request, 2);
// decode the data
$sig = base64_url_decode($encoded_sig);
$data = json_decode(base64_url_decode($payload), true);
if (strtoupper($data['algorithm']) !== 'HMAC-SHA256') {
error_log('Unknown algorithm. Expected HMAC-SHA256');
return null;
}
// check sig
$expected_sig = hash_hmac('sha256', $payload, $secret, $raw = true);
if ($sig !== $expected_sig) {
error_log('Bad Signed JSON signature!');
return null;
}
return $data;
}
function base64_url_decode($input) {
return base64_decode(strtr($input, '-_', '+/'));
}