What is valid and what is invalid to send to Elasticsearch Bulk? - elasticsearch

I need a comprehensive list of what is valid and what is invalid when sending a bulk payload to ElasticSearch.

Bulk endpoint is a indexing endpoint. So at a highlevel you can only send indexing requests to that endpoint.
Since its bulk, a valid request is designed around multiple doc and how they are delimited. e.g. if you can not using a ES client then you will need to have payload formatted as ndjson (new delimited json) and last doc should end in a new line as well. Better to use a client since a client will do this all for you.
Apart from syntax of payload data you can target a index , a type etc in URL.
You can also send some other param like "wait_for_completion", "retry_on_conflict" etc. These are parameter which will control how each requests will behave.
Needless to say but best would be to read up the doc:
https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-bulk.html

Related

c# unity get data from Elasticsearch Restful API

I am new to Elasticsearch. What I need to do now is send a specific query to the DB and receive the result from Unity via the rest of the API.
maybe [unity] ---query--> [DB] ---data--> [restful API] ---> [unity] this is I want it program
I make unity navigator IoT...
I want the Unity navmesh agent to move (e.g. coordinates x, y, z) by receiving data from Elasticsearch once every 3 seconds. get request is http:localhost:9200/location/_search?q=x:6.7 this URL result just 1 data but It contains headers, so I don't know how to do it.
elasticsearch send data term 3seconds possible?
how to get data only result no include header
somebody help me..... ㅠㅠㅠㅠㅠㅠㅠ
This is what I did. You can send a GET request to your DB endpoint, and append your query to the end of the url.
https://xxxxx.northamerica-northeast1.gcp.elastic-cloud.com:xxxx/xxxx/_search?&size=1&sort=timestamp:desc
The above query returns me the latest entry in my xxxx cluster.
Once you get the data you wanted, you can use JSON deserialization to deserialize them into your customized object. You are then able to use anything you want without the header.
To get data once per 3 seconds you can use a coroutine to send the GET request every 3 seconds.

NiFi transfering data between processors

I want to create a simple flow. Firstly, I need to take accountIds from REST service and then use received values to create new HTTP request to get token, and then use this token to create some requests with Oauth2.
AccountIds flow:
From InvokeHttp I'll receive some ids in json (REST written in Java and returns List with Integers). 99% chance that there will be only one number. My response looks like: [40]. Now I need to replace square brackets and get this number (using SplitJson). This number I should put to the next getToken as one of the GET param (on a screenshot i hardcode this):
This will return a token. Token is a text/plain;charset=UTF-8. And then, i want to use InvokeHttp again, add atribute Authorization and add to this attribute Bearer + received token. I do not really understand how to use the received data from processors in the following processors. Can someone explain how to reach it with my flow?
The Rest Api provides you with payload body - in nifi terms a flowfile content, you need to parse that incoming content using an evaluatejson (if payload is json - in most cases) and store it in flow attributes.
Then this attributes will be used in the down stream processors.
Also to pass the Authorization to your InvokeHTTP you need to decalre it in the InvokeHTTP porcesor. The ${access_token} is from the upstream attributes extraction.

How to do routing and avoid deserialization in Grpc / Protobuf?

In our Java app we need to accept a (large) Grpc message, extract a field, and then based on the value of that field forward the message on to another server.
I'm trying to avoid the overhead of completely deserializing the message before passing it on.
One way to do this would be to send the field as a separate query or header parameter, but Grpc doesn't support them.
Another way would be to extract just the field of interest from the payload, but Protobuf doesn't support partial or selective deserialization.
How else can I do this?
One way you can do this is by doing it on the server side. When the server is about to send a response, it can extract the field and set it as part of the initial headers sent. You can do this by using a ServerInterceptor to extract the field that you want from the response and add it to the Metadata.
Aside from that, Protocol buffers currently require that you parse the message before accessing the internal fields.

Multiple data elements in single Parse Push RETS API request

I was wondering if here is a way to send multiple 'data' elements in a single Parse REST API push request. I know we can send the same message to multiple devices or channels as required. But i have a different message for each channel. So what i need is a way to call Parse REST API once with the JSON of different channels but each with a different data and alert message.
is is possible? or do i need to make such requests one by one.

HTTP POST - nameless data VS named data

Our server A notifies 3rd party server B with an XML-formatted message, sent as HTTP POST request. It's us who specify the message format and other aspects of interaction.
We can specify that the XML is sent as
a) raw data (just the XML)
b) single POST parameter having some specific name (say, xml=XML)
The question is which way is better for the 3rd party in general, if we don't know the platform and language they are using.
I thought I had seen some problems in certain languages to easily parse the nameless raw data, though I don't remember any specific case. While my colleague insists that the parameter name is redundant, and it's really better to send the raw data without any name.
If you don't need send extra information in other post parameters the xml parameter name is redundant and innecesary as your teammate said, if the 3rd party waits only for a XML data only send the raw data in the POST body with the correct mime type and encoding and and do not complicate.
The process for Getting raw data is easy in most application server containers, so you dont care about that, most of them uses a Reader to get received data and manipulate it.

Resources