Comments (5)
// Sample code that demonstrates the problem:
package examples;
import com.marklogic.client.io.*;
import com.marklogic.client.document.DocumentPage;
import com.marklogic.client.document.DocumentRecord;
import com.marklogic.client.document.JSONDocumentManager;
import com.marklogic.client.document.DocumentManager.Metadata;
import com.marklogic.client.DatabaseClientFactory;
import com.marklogic.client.DatabaseClient;
public class standalone {
// replace with your MarkLogic Server connection information
static String HOST = "kim-3.marklogic.com";
static int PORT = 8003;
static String USER = "admin";
static String PASSWORD = "adm1n";
static DatabaseClient client = DatabaseClientFactory.newClient(
HOST, PORT,
USER, PASSWORD,
DatabaseClientFactory.Authentication.DIGEST);
public static void example2() {
JSONDocumentManager jdm = client.newJSONDocumentManager();
jdm.setMetadataCategories(Metadata.QUALITY);
DocumentPage documents = jdm.read("doc1.json", "doc2.json", "doc3.json");
while (documents.hasNext()) {
DocumentRecord document = documents.next();
System.out.print(document.getUri() + ": ");
// StringHandle content = document.getContent(new StringHandle());
DocumentMetadataHandle metadata = document.getMetadata(new DocumentMetadataHandle());
System.out.println(document.getUri() + ": " + metadata.getQuality());
// System.out.println(content.toString());
}
}
public static void main(String[] args) {
example2();
}
}
from java-client-api.
p.s. I forgot to say, it should be reproducible with any documents, but I had inserted mine with the following function, which you can probably drop into the same package and run, +/- an import or two.
public static void exampleA() {
// Synthesize input content
StringHandle doc1 = new StringHandle(
"{\"number\": 1}").withFormat(Format.JSON);
StringHandle doc2 = new StringHandle(
"{\"number\": 2}").withFormat(Format.JSON);
StringHandle doc3 = new StringHandle(
"{\"number\": 3}").withFormat(Format.JSON);
StringHandle doc4 = new StringHandle(
"{\"number\": 4}").withFormat(Format.JSON);
StringHandle doc5 = new StringHandle(
"{\"number\": 5}").withFormat(Format.JSON);
// Synthesize input metadata
DocumentMetadataHandle defaultMetadata1 =
new DocumentMetadataHandle().withQuality(1);
DocumentMetadataHandle defaultMetadata2 =
new DocumentMetadataHandle().withQuality(2);
DocumentMetadataHandle docSpecificMetadata =
new DocumentMetadataHandle().withCollections("myCollection");
// Create and build up the batch
JSONDocumentManager jdm = client.newJSONDocumentManager();
DocumentWriteSet batch = jdm.newWriteSet();
// use system default metadata
batch.add("doc1.json", doc1); // system default metadata
// using batch default metadata
batch.addDefault(defaultMetadata1); // XXX this needs a name change
batch.add("doc2.json", doc2); // batch default metadata
batch.add("doc3.json", docSpecificMetadata, doc3); // XXX add back when bug fixed
batch.add("doc4.json", doc4); // batch default metadata
// replace batch default metadata with new metadata
batch.addDefault(defaultMetadata2); // XXX this needs a name change
batch.add("doc5.json", doc5); // batch default
// Execute the write operation
jdm.write(batch);
// Check the results
// Doc1 should have the system default quality of 0
System.out.println("doc1 quality: Expected=0, Actual=" +
jdm.readMetadata("doc1.json", new DocumentMetadataHandle()).getQuality()
);
// Doc2 should use the first batch default metadata, with quality 1
System.out.println("doc2 quality: Expected=" +
defaultMetadata1.getQuality() + ", Actual=" +
jdm.readMetadata("doc2.json", new DocumentMetadataHandle()).getQuality()
);
// Doc3 should have the system default document quality (0) because quality
// was not included in the document-specific metadata. It should be in the
// collection "myCollection", from the document-specific metadata.
DocumentMetadataHandle doc3Metadata =
jdm.readMetadata("doc3.json", new DocumentMetadataHandle());
System.out.println("doc3 quality: Expected=0, Actual=" + doc3Metadata.getQuality());
System.out.print("doc3 collections: Expected: myCollection, Actual=");
for (String collection : doc3Metadata.getCollections()) {
System.out.print(collection + " ");
}
System.out.println();
// Doc 4 should also use the 1st batch default metadata, with quality 1
System.out.println("doc4 quality: Expected=" +
defaultMetadata1.getQuality() + ", Actual=" +
jdm.readMetadata("doc4.json", new DocumentMetadataHandle()).getQuality()
);
// Doc5 should use the 2nd batch default metadata, with quality 2
System.out.println("doc5 quality: Expected=" +
defaultMetadata2.getQuality() + ", Actual=" +
jdm.readMetadata("doc5.json", new DocumentMetadataHandle()).getQuality()
);
}
from java-client-api.
Gah, lunchtime food coma. Sorry. THIS REST request:
curl --anyauth --user admin:adm1n -H "Accept: multipart/mixed; boundary=BOUNDARY" -X GET http://localhost:8003/v1/documents?uri=doc1.json&uri=doc2.json&uri=doc3.json&category=quality
(The one in the original problem description was missing Accept headers).
from java-client-api.
Set status to Fix on behalf of bugtrack integration.
Should this still be assigned to Charles now that Sam is back? For some reason, I actually thought this had been fixed, though I haven't tried it to confirm.
from java-client-api.
Verified
from java-client-api.
Related Issues (20)
- DMSDK has troubles with tiered storage offline HOT 8
- Transfer Encoding has non-emtpy body when no result in returned through okhttp HOT 3
- op.sampleBy misses the 0 parameter overloaded method HOT 1
- Delete temporal documents via DMSDK HOT 2
- Specifi page length and startIndex for dataMOvementManager using newQueryBatcher HOT 3
- Upgrade to jackson-databind 2.14.0 when available HOT 2
- WriteBatcher does not write documents when total documents provided is less than 100 and without using withBatchSize HOT 1
- SparQL query throws unexpected error HOT 3
- Executing PatchHandle against non-existing Document does not throw an Exception HOT 5
- Incorrectly return empty query result HOT 3
- Support for Java 17? HOT 8
- Numbers returned by MarkLogic do not use scientific notation HOT 1
- Implementations of innerSerialize lack proper namespace HOT 11
- Feature Request: OptimisticLockingExecption HOT 7
- Request for Jakarta EE 10 compliant version HOT 18
- Remove "ML-Check-ML11-Headers" for ML11 java client api HOT 1
- Directory queries allow for invalid values of "depth" without throwing an error HOT 3
- Wrong timeout conversion in awaitCompletion HOT 4
- search:and-not-query is ignored in QueryBatcher HOT 6
- queryManager.uris does not honor additional-query in search options HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from java-client-api.