How make aws-curl exlude fields from elasticsearch? - amazon-web-services

I am trying to send a request to aws elasticsearch with aws-es-curl:
aws-es-curl https://myhost.es.amazonaws.com/my-index/_search?pretty -H 'Content-Type: application/json' -d'{"query":{"match_all":{}},"size": "100","index":"my-index", "_source": {"excludes": ["attachment.*","data"], "includes": "owner"}}'
But this returns me all fields. Also I size parameter is also not recognized :( Why this happens? How pass those parameters to es?
ES version is 5.3
Source variants are here

Try to pipe the content of your query into the curl command:
echo '{"query":{"match_all":{}},"size": "100", "_source": {"excludes": ["attachment.*","data"], "includes": "owner"}}' | aws-es-curl -X POST https://myhost.es.amazonaws.com/my-index/_search

Related

How to create an index pattern in Opensearch using API?

I want to create an index pattern using Opensearch API. I tried to replicate what could be made graphically in the following image window, using as index pattern name cwl-* and then as time field #timestamp.
My domain has OpenSearch 1.2 installed.
Using curl (directly modifiend the command in kibana doc):
curl -u '****:*****' -X POST "https://******.eu-central-1.es.amazonaws.com/api/index_patterns/index_pattern" -H 'osd-xsrf: true' -H 'Content-Type: application/json' -d'
{
"index_pattern": {
"title": "cwl-*",
"timeFieldName": "#timestamp"
}
}'
but I receive
{"error":{"root_cause":[{"type":"illegal_argument_exception","reason":"Rejecting mapping update to [api] as the final mapping would have more than 1 type: [_doc, index_patterns]"}],"type":"illegal_argument_exception","reason":"Rejecting mapping update to [api] as the final mapping would have more than 1 type: [_doc, index_patterns]"},"status":400}
curl -u '****:*****' -X POST "https://******.eu-central-1.es.amazonaws.com/api/index_patterns/cwl-*" -H 'osd-xsrf: true' -H 'Content-Type: application/json' -d'
{
"index_pattern": {
"title": "cwl-*",
"timeFieldName": "#timestamp"
}
}'
change api/index_patterns/index_pattern to api/index_patterns/cwl-* and try again?
It worked for me in OpenSearch 1.3 when I added an ID in the URI and used saved_objects instead of index_patterns.
So your cURL-request should work when looking like this.
curl -u '****:*****' -X POST "https://<opensearch-dashboards-host>.eu-central-1.es.amazonaws.com/api/saved_objects/index-pattern/<ID>"
-H 'osd-xsrf: true'
-H 'Content-Type: application/json'
-d
'{
"index_pattern": {
"title": "cwl-*",
"timeFieldName": "#timestamp"
}
}'

How do I get the stats of all the pillars on the Zenon Network?

Is there an easy way to get all the statistics on the pillars on the Zenon Network?
You can use curl on the command line and access the method: embedded.pillar.getAll (https://testnet.znn.space/#!api.md)
I passed the output to the command jq so it can be easily read.
curl -X POST http://127.0.0.1:35997 -H 'Content-Type:
application/json' -d '{"jsonrpc": "2.0", "id": 20, "method":
"embedded.pillar.getAll","params": [0, 299]}' | jq
This will give you the output of:

How to convert curl command to postman(PayPal disputes API)

I encountered a problem while developing here
This curl command is something I have n’t encountered before and it has n’t been resolved for a long time
Please help me
How to convert to postman format, my import using postman cannot be recognized correctly
code:
curl -v -X POST https://api.sandbox.paypal.com/v1/customer/disputes/PP-D-27803/provide-evidence \
-H "Content-Type: multipart/related; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW" \
-H "Authorization: Bearer Access-Token" \
-F 'input={
"evidences": [
{
"evidence_type": "PROOF_OF_FULFILLMENT",
"evidence_info": {
"tracking_info": [
{
"carrier_name": "FEDEX",
"tracking_number": "122533485"
}
]
},
"notes": "Test"
}
]
};type=application/json' \
-F 'file1=#NewDoc.pdf'
我自己解决了
看图片
目前只能使用curl成功 postman python requests php 都没有成功
主要还是后面这个#符号
enter image description here

Trained a text-classification model and want to pass a .csv file with text items to predict

I have already trained my data set in Google auto ml. Now I want to pass a CSV with text items to predict its labels. Not sure on how to proceed
Have passed 17k text items with labels.
Have seen rest API & python codes to execute.
export GOOGLE_APPLICATION_CREDENTIALS=key-file-path
curl -X POST \ -H "Authorization: Bearer $(gcloud auth application-default print-access-token)" \ -H "Content-Type: application/json" \ https://automl.googleapis.com/v1beta1/projects/ticket-classification-poc/locations/us-central1/models/TCN8669499774734365168:predict \ -d '{ "payload" : { "textSnippet": { "content": "YOUR TEXT HERE", "mime_type": "text/plain" }, } }' Output : Need to pass future text items in bulk for prediction
You need to have a loop to go through all the CSV items programatically and send one by one.

google speech api Invalid recognition

I am trying to follow the example on google speech api found here
https://cloud.google.com/speech/docs/getting-started
1) I created the follow json request file
{
'config': {
'encoding':'FLAC',
'sampleRate': 16000,
'languageCode': 'en-US'
},
'audio': {
'uri':'gs://cloud-samples-tests/speech/brooklyn.flac'
}
}
2) Authenticate to my service account
gcloud auth activate-service-account --key-file=service-account-key-file
3) Obtain my authorization token successfully
gcloud auth print-access-token
access_token
4) Then use the following curl command
curl -s -k -H "Content-Type: application/json" \
-H "Authorization: Bearer access_token" \
https://speech.googleapis.com/v1beta1/speech:syncrecognize \
-d #sync-request.json
But I keep getting the following response
{
"error": {
"code": 400,
"message": "Invalid recognition 'config': bad encoding..",
"status": "INVALID_ARGUMENT"
}
}
Do I need access permissions for the uri gs://cloud-samples-tests/speech/brooklyn.flac? Is that what the problem is?
Thanks in advance..
In my opinion, it is a file format issue.
You have to send WAV file instead of FLAC ...
[ FLAC and MP3 format are not supported <=> need a file conversion (representing cost) on the server side ]
Convert your audio file to WAV (using ffmpeg or avconv), then retry.
You may also take a look here (to see a working example)
For me, the solution was to remove the space between "-d #",
so change "-d #sync-request.json" to "-d#sync-request.json".
I got help here: https://groups.google.com/forum/#!topic/cloud-speech-discuss/bL_N5aJDG5A. Apparently the file was being read and processed, but the parms were going to the "curl.exe" instead of being passed to the URL.
I understand this is quite late for an answer. However, it might help others so putting in your error.
The config that you are passing is actually incorrect. The attributes should be like:
{
"config": {
"encoding": "LINEAR16",
"sampleRateHertz": 16000,
"languageCode": "en-US",
"maxAlternatives": 1,
"profanityFilter": true,
"enableWordTimeOffsets": false
},
"uri": {
"content":"<your uri>"
}
}