I am working on a project which uses Elasticsearch 5.4 as a datastore. I need to update a field in all the documents in a index. We are using Java RestClient for connection between Java and Elasticsearch and i am not able to find any documentation or Resources for Update API in RestClient 5.4.3.
Can someone please guide me how to proceed from here!
Note : I cannot use Transport client.
Thanks
Did you try to perform POST request on _update_by_query endpoint?
Please take a look on Update By Query API:
The simplest usage of _update_by_query just performs an update on every document in the index without changing the source.
and
So far we’ve only been updating documents without changing their source. That is genuinely useful for things like picking up new properties but it’s only half the fun. _update_by_query supports a script object to update the document.
Related
I am not an expert in this so forgive any bad coding you may see in my project.
I building an app that lets the user create, read, update and delete ingredients and recipes which can then be used to make grocery lists. I am using Java with Spring Boot as the back end, MongoDB as the database and AngularJS as the front end. Creating, reading and deleting works just fine, but updating is not working for the recipe collection in the DB.
When I run the back end server and use postman to make a PUT request to update a recipe, the recipe in the body of the request gets inserted as a new document even though I specify the ObjectID of an existing recipe. I don't have this problem with the ingredient collection. I suspect it has something to do with the fact that the recipe documents are nested JSON objects, while the ingredient documents are not, but I may be wrong.
I have uploaded the Java back end of the project to gitHub: https://github.com/firo8/grocerylists/tree/master/grocery-list/src/main/java/com/firo/grocerylist.
I have searched everywhere and can't find anyone else that has this problem with an answer I can understand. E.g. the following question seems to be similar, but the answer is not helpful: PUT makes POST instead of updating value in Spring Boot
what can I do to fix this?
Thanks in advance
Please refer to below docs on spring mongo db support page.
https://docs.spring.io/spring-data/mongodb/docs/3.0.3.RELEASE/reference/html/#mongo.core
I see that you need to connect the database by creating a mongo client and use mongo template to insert/update/get/delete from mongo db.
Follow the docs to get it working.
I saw already answered questions and seems they are old enough that I couldn't use them. I tried an example given at https://www.elastic.co/blog/found-java-clients-for-elasticsearch which has the code written but not in an organized manner that would help me. The libraries are old and code gives me error.
I saw Spring Data project but that only allow a specific type of document/class to be indexed and needs the model to be predefined which is not my usecase. My goal is to build a java web application which could ingest any data documents fed to elasticsearch and we could analyze it with Kibana. I would need to know how can i fire a rest call or curl for bulk data. Can anyone state an example with complete parts please.
Use rest client.
The Java High Level REST Client works on top of the Java Low Level
REST client. Its main goal is to expose API specific methods, that
accept request objects as an argument and return response objects, so
that request marshalling and response un-marshalling is handled by the
client itself.
To upload data from java application to ES , you can use bulk Api.
To check list of APIs check link
I'm trying to access a WFS source by using the GeoTools WFS plugin as presented here.
However, the layer I'm trying to fetch is only accessible through a proxy, and the GetCapabilities page has the plain URLs (ie. not the proxy URLs). Thus, my requests fail as the WFS plugin attempts a DescribeFeatureType request to the wrong URL.
Is there any way to just fetch a certain GetFeature-layer, without having to query the feature schema? Could I somehow supply the schema to the plugin so no query is made?
The WFS-NG module is now the prefered GeoTools wfs module. However, it won't help with this issue either I'm afraid.
The best solution is to fix the server you are using (if it is a GeoServer you can change the base URL). Alternatively may be you can apply an XSLT (or regexp) to the incoming capabilities document?
Finally you can look at modifying the GeoTools code to allow the end user to supply a URL (or to guess it from the getCapababilities URL). Please read the contribution guide lines. It would certainly do no harm to create a feature request in the issue tracker.
I have been using SOAPAPI earlier to create and update records from a remote system to salesforce. Then I added an additional functionality of oAuth 2.0 in my application. But on making connection with this oAuth, SOAP's upsert or any other query method refused to accept the connection made by it. Then I tried to switch it to Rest API.
Again there is an issue since one can send record one by one in REST. Last option for me is BulkAPI. But I could not find any sample example to create or update a record using a list. Everywhere this Bulk API is used with csv file. But I need to pass record from a list of objects as it is done with SOAP.
Can anyone provide me some sample example or if this can only be done with csv file then, is there any alternative to use same approach for list?
If you looking for code examples of data upload with Bulk API, you can find it in Salesforce Developer documentation, for instance - Walk Through the Sample Code. There is example of uploading data from CSV file.
Also I recommend you to read Bulk API Developer Guide and specially to consider Bulk API Limits for better understanding how it is suitable for your case.
UPD: Here is repo with an example of using Salesforce Bulk API from C#.
I tried adding members using Java library ecwid and using post request and I am able to do that but I am not getting how we can add members in batches using API.
V3.0 of API has not implemented batch operation as yet. What about V2.0, somebody is able to do it?
In v2.0, the call you're looking for is batchSubscribe().