Comments (8)
// Sample code demonstrating the bug. I don't think it matters what docs you have in the db.
package examples;
import com.marklogic.client.io.*;
import com.marklogic.client.query.QueryManager;
import com.marklogic.client.query.RawQueryByExampleDefinition;
import com.marklogic.client.DatabaseClientFactory;
import com.marklogic.client.DatabaseClient;
public class bug {
// replace with your MarkLogic Server connection information
static String HOST = "localhost";
static int PORT = 8003;
static String USER = "user";
static String PASSWORD = "password";
static DatabaseClient client = DatabaseClientFactory.newClient(
HOST, PORT,
USER, PASSWORD,
DatabaseClientFactory.Authentication.DIGEST);
public static void xmlQBE() {
QueryManager qm = client.newQueryManager();
String queryAsString =
"<q:qbe xmlns:q='http://marklogic.com/appservices/querybyexample'>"+
"<q:query>" +
"<kind>bird</kind>" +
"</q:query>" +
"</q:qbe>";
RawQueryByExampleDefinition query =
qm.newRawQueryByExampleDefinition(new StringHandle(queryAsString));
StringHandle report = qm.validate(query, new StringHandle());
System.out.println(report.toString());
SearchHandle results = qm.search(query, new SearchHandle());
System.out.println(results.getTotalResults());
}
public static void jsonQBE() {
QueryManager qm = client.newQueryManager();
String queryAsString = "{ \"$format\": \"xml\", \"$query\": { \"kind\": \"bird\" } }";
StringHandle handle = new StringHandle();
handle.withFormat(Format.JSON).set(queryAsString);
RawQueryByExampleDefinition query =
qm.newRawQueryByExampleDefinition(handle);
StringHandle report = qm.validate(query, new StringHandle());
System.out.println(report.toString());
SearchHandle results = qm.search(query, new SearchHandle());
System.out.println(results.getTotalResults());
// StringHandle works and returns JSON output
// StringHandle results = qm.search(query, new StringHandle());
// System.out.println(results);
}
public static void main(String[] args) {
xmlQBE(); // works
jsonQBE(); // doesn't work
}
}
from java-client-api.
Hi Kim, I ran into a similar error with JSON and bulk read/search.
I wanted to get back JSON search results, so reached into the implementation class:
JacksonHandle searchHandle = new JacksonHandle();
JSONDocumentManager docMgr = newJSONDocumentManager(role);
((JSONDocumentImpl) docMgr).setResponseFormat(Format.JSON);
DocumentPage page = docMgr.search(qdef, start, searchHandle);
This results in the "repeated parameter" error.
I would have liked JacksonHandle to simply work .. this also throws an error:
java.lang.UnsupportedOperationException: The format supported by your handle:[JSON] does not match your setResponseFormat:[XML]
at com.marklogic.client.impl.DocumentManagerImpl.search(DocumentManagerImpl.java:363)
from java-client-api.
I have run into the repeated param error as well, in a context that doesn't involve JacksonHandle. it was previously filed as issue #30.
from java-client-api.
Looks like the issue here is the format parameter I'm sending to /v1/qbe. If you change your example, Kim, to use JacksonHandle in place of SearchHandle, it works fine. It sends a request to REST equivalent to this curl command:
curl --digest --user rest-writer:x -H "Content-Type: application/json" -H "Accept: multipart/mixed" -d '{ "$query": { "kind": "bird" } }' -X POST http://localhost:8012/v1/qbe?pageLength=50&format=json&view=results
But that means you won't get the convenience methods of SearchHandle. If we weren't doing a bulk request I could change the accept header to "application/xml" and we'd get xml results as desired. But with bulk I need my accept header to be "multipart/mixed". If I remove the format parameter I get the desired behavior:
curl --digest --user rest-writer:x -H "Content-Type: application/json" -H "Accept: multipart/mixed" -d '{ "$query": { "kind": "bird" } }' -X POST http://localhost:8012/v1/qbe?pageLength=50&view=results
But I struggle with this because it's not explicit. If I wanted it, I'm not sure how I would get back a JSON search response if my documents were XML and therefore my QBE was XML. Let's see what Erik thinks.
from java-client-api.
I think I backed into this problem while trying to figure out why I was having problems with a bulk read using QBE and trying to return search results, but my example isn't intended to be a bulk read. Notice it is using QueryManager.search() rather than DocumentManager.search(). It's a regression on a plain ol' QBE search.
The Accept header probably shouldn't be multipart/mixed at all..That's one problem.
The other, perhaps lesser, problem is that we used to only support returning search results as XML, so SearchHandle.withFormat will not let you set the results to JSON, even though we now seem to want to return them as JSON by default with a JSON query.
from java-client-api.
Thanks, Kim. That's what I get for visually inspecting your code --I thought I'd seen the differences between this and #30, but I obviously missed some.
from java-client-api.
Reassigning to QA for testing.
from java-client-api.
Verified with bulk search.
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.