How can I upload multiple records in a file into marklogic server using RESTapi.
I tried to insert simple json format file
[{"Id":100000,"Name":"Dennis"},
{"Id":100001,"Name":"Andrea"},
{"Id":100002,"Name":"Robert"},
{"Id":100003,"Name":"Sara"}]
But, it gives me like one single record.
How do I convert this into 4 different records?
Thanks in advance,
Y.Prithvi
There isn't an out-of-the-box way to do that split at the moment. Your best bet is to do a client-side split and then do a bulk-write POST with multiple JSON items to /v1/documents
For the client-side split, you might use something like underscore_cli to do the splitting.
As Dave points out, the easiest approach is to split out the documents on the client and send a multipart/mixed payload.
The alternative is to write a resource service extension to do the split. In MarkLogic 7, the service must be implemented in XQuery. In MarkLogic 8, you will also be able to implement a service in JavaScript.
The Java API bundles an example that illustrates the basic idea of a service that splits documents:
scripts/docsplit.xqy
com.marklogic.client.example.extension.DocumentSplitter
Related
I’m trying to use a REST API call to find all envelopes with subjects that are either {{cSubject_1}} OR {{cSubject_2}}.
I’m using "search_text" for filtering but I’m not sure how I should use the logical operator for “OR” for this purpose.
I would appreciate if you could help me with this.
Thanks,
Kathy
There's currently no support for this type of complex query in the search_text for The Envelopes:listStatusChanges endpoint.
The search_text allows you to have a single text item that is search across the board (recipients, subject, etc.) and is not limited to a specific meta-data. You can use other filters to filter by other means.
I would recommend storing envelope's meta-data in your application storage (or database) and using your own code to query this information if possible.
In parse server, have to update multiple rows of the a table by REST API Is there anyway I can achieve this instead of looping the record and update each of them.
You're better off using Batch Operations.
You can define a function in the cloud code to perform your service: Parse.Cloud.define
I'm using NiFi to get data from an Oracle database and put some of this data in Kafka (using the processor PutKafka).
Example : if the attribute "id" contains "aaabb"
Is that possible in Apache NiFi? How can i do it?
This should definitely be possible, the flow might be something like this...
1) ExecuteSQL or QueryDatabaseTable to get the data from the database, these produce Avro
2) ConvertAvroToJson processor to convert the Avro to Json
3) EvaluateJsonPath to extract the id field into an attribute
4) RouteOnAttribute to route flow files where the id attribute contains "aaabbb"
5) PutKafka to deliver any of the matching results from RouteOnAttribute
To add on to Bryan's example flow, I wanted to point you to some great documentation that should help introduce you to Apache NiFi.
Firstly, I would suggest checking out the NiFi documentation. It is very good and should help a lot. In addition to providing details on each of the processors Bryan mentioned it also has general documentation for every type of user.
For a basic introduction to build a NiFi flow check out this video.
For example templates check out this repo. It's a has an excel file at it's root level which has a description and list of processors for each template.
What I meant was: How do we know what requests a particular URI of the container accepts and what parameters we can use?
For example:
the container URI: http://example.com/containers/container1
-> Now I want to know a way to access the metadata of the container. How do I do it?
The main reason I am trying to ask this question is I am working on migration of Fedora Commons from 3 to 4. And I am confused by many different schemas and notations. In some places, they use http://something.com/smthng/fcr:metadata.
At some places, they use http://something.com/smthng/metadata. Sometimes, fedora namespace will work in the URI and in some places it won't work. I am confused.
I want to know a way to know to all the accepted conventions on a URI.
I really don't think you have to go beyond Wikipedia's Uniform Resource Identifier definition to understand the standards for URIs, URLs and URNs.
However, the question is more likely about the Linked Data Platform. If you go to Concept Mapping - Fedora 3 to 4 , the links for Fedora 4 go to the W3C Linked Data Platform (LDP) recommendation. That basically states how the REST API works to query RDF data.
LDP containers are a way to partition RDF data so you can query the container and get a list of RDF resources. I don't think there is a way to query their metadata. The set of available containers defined in the data itself, and are not required. I.e. the data may be entirely defined with resources and containers are just a way to partition RDF data. If you have SPARQL access to the data, one idea is to query the data looking for LDP containers. Then you can sent REST requests to get that data.
(BTW, A RDF text serialization is a text-based representation of RDF graphs. Using a text serialization allows users to exchange data in a standard format. RDF standards include RDF/XML, Turtle, N-Triples, and JSON-LD.)
I have already gone through this
How best to design a REST API with multiple filters?
This does help when you have say 3 or 4 filtering criteria and you can accomodate that in the query String.
However let's take this example
You want to get call details about 20 telephone numbers, between a certain startdate and enddate.
Now I do agree ideally one should be advised to make individual queries for each number and then on the client side collate all data.
However for certain Live systems that would mean 20 rounds of queries on the switches or cdr databases. That is 20 request-response cycles plus the client having to collate and order them again based on time. While in the database level it would have been a simple single query that can return an ordered data and transformed back into a REST xml response that the client can embed on their system.
If we are to use GET the query string will get really confusing and has a limit as well.
Any suggestions to get around this issue.
Of course we can send a POST request with an xml having all numbers in it but that is against REST Get principles.
In case of GET use OData queries. For example when your start and end dates represented as numbers (unix time) URI could look like:
GET http://operatorcalls.com/Calls/Details?$filter=Date le 1342699200 and Date gt 1342526400
What you seem to be missing is an important concept of REST, caching. This can be done, as an example, in the browser, for a single client. Or it can be done as a shared cache between all the clients and the live production system (whatever it may be). Thus reducing queries against a live production system, or in your example, actual switches.
You should really take some time to read Fieldings thesis, and understand that REST is an architectural style.
I found a solution here Handling multiple parameters in a URI (RESTfully) in Java
but not quite happy with it.
So in effect we will end up using /cdr?numbers=number1,number2,number3 ...
However not too pleased with it as there is a limit to Query String in the url and also doesn't really seem to be an elegant solution. Anyone found any solution to this in their own implementation?
Basically not using POST for this kind of Fetch requests and also not using cumbresome and lengthy Query Strings.
We are using Jersey but also open to using CXF or Spring REST