I am new to Marklogic and probably missing something. I'm using MarkLogic 7.0, java-client-api 2.0.5. Having created a new REST instance, I'm trying to run sample code offered by Marklogic:
DatabaseClient client =
DatabaseClientFactory.newClient("some.host.com", 8006, "user", "****",
DatabaseClientFactory.Authentication.DIGEST);
JSONDocumentManager doc = client.newJSONDocumentManager();
doc.write(
"hello.json",
new StringHandle("{\"recipient\": \"world\", \"message\": \"Hello, world!\"}"));
QueryManager query = client.newQueryManager();
StructuredQueryBuilder b = query.newStructuredQueryBuilder();
SearchHandle results =
query.search(
b.and(b.term("hello"), b.value(b.jsonKey("recipient"), "world")),
new SearchHandle());
for (MatchDocumentSummary summary : results.getMatchResults()) {
System.out.println(doc.read(summary.getUri(), new StringHandle()).toString());
}
But I am getting the following error
com.marklogic.client.FailedRequestException: Local message: search failed: Bad Request. Server Message: REST-INVALIDPARAM: (err:FOER0000) Invalid parameter: Invalid query structure (check namespace): <query xmlns:search="http://marklogic.com/appservices/search" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><and-query><term-query><text>hello</text></term-query><value-query><json-key>recipient</json-key><text>world</text></value-query></and-query></query>
at com.marklogic.client.impl.JerseyServices.search(JerseyServices.java:1893)
at com.marklogic.client.impl.JerseyServices.search(JerseyServices.java:1703)
at com.marklogic.client.impl.QueryManagerImpl.search(QueryManagerImpl.java:199)
at com.marklogic.client.impl.QueryManagerImpl.search(QueryManagerImpl.java:162)
What is the reason of that? Is that because of some server configuration and I need to adjust the code somehow? (I don't have admin rights and have MarkLogic server already configured)
P.S. After I installed MarkLogic on another machine and ran the same code there, it worked fine.
Thanks, Hlib
UPDATE:
答案 0 :(得分:1)
我从类路径中删除了 woodstox库。正如@SamMefford所提到的,它导致XMLStreamWriter行为不端。之后一切正常。