Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable QueryBatcher to take in a RawCtsQueryDefinition #965

Closed
vivekmuniyandi opened this issue Jul 23, 2018 · 6 comments
Closed

Enable QueryBatcher to take in a RawCtsQueryDefinition #965

vivekmuniyandi opened this issue Jul 23, 2018 · 6 comments

Comments

@vivekmuniyandi
Copy link
Contributor

Right now QueryBatcher can't take in a Raw Cts Query and process results based on the Cts query passed. We need to enable QueryBatcher to take in a RawCtsQueryDefinition in order to accomplish this.

@vivekmuniyandi
Copy link
Contributor Author

Trunk - Committed revision 291425.
b9 - Committed revision 291424.

vivekmuniyandi added a commit to vivekmuniyandi/java-client-api that referenced this issue Aug 1, 2018
@vivekmuniyandi
Copy link
Contributor Author

This has a server dependency. Hence 4.1.1 should be aligned with 9.0.7 or it should be released later.

@georgeajit
Copy link
Contributor

Running a test with RawCtsQueryDefinition on a QuerBatcher instance produces REST-UNSUPPORTEDPARAM

The stack trace is:

com.marklogic.client.datamovement.QueryBatchException: com.marklogic.client.FailedRequestException: Local message: failed to apply resource at internal/uris: Bad Request. Server Message: REST-UNSUPPORTEDPARAM: (err:FOER0000) Endpoint does not support query parameter: invalid parameters: <cts:word-query xmlns:cts
	at com.marklogic.client.datamovement.impl.QueryBatcherImpl$QueryTask.run(QueryBatcherImpl.java:656)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
	at java.lang.Thread.run(Thread.java:748)
Caused by: com.marklogic.client.FailedRequestException: Local message: failed to apply resource at internal/uris: Bad Request. Server Message: REST-UNSUPPORTEDPARAM: (err:FOER0000) Endpoint does not support query parameter: invalid parameters: <cts:word-query xmlns:cts
	at com.marklogic.client.impl.OkHttpServices.checkStatus(OkHttpServices.java:4280)
	at com.marklogic.client.impl.OkHttpServices.postResource(OkHttpServices.java:3264)
	at com.marklogic.client.impl.OkHttpServices.postResource(OkHttpServices.java:3210)
	at com.marklogic.client.impl.OkHttpServices.postResource(OkHttpServices.java:3201)
	at com.marklogic.client.impl.OkHttpServices.uris(OkHttpServices.java:2954)
	at com.marklogic.client.impl.QueryManagerImpl.uris(QueryManagerImpl.java:179)
	at com.marklogic.client.datamovement.impl.QueryBatcherImpl$QueryTask.run(QueryBatcherImpl.java:607)

...
...
// Verify with RawCtsQuery
String wordQuery = "<cts:word-query xmlns:cts="http://marklogic.com/cts\">" +
"cts:textgroundbreaking</cts:text></cts:word-query>";
StringHandle handle = new StringHandle().with(wordQuery);
RawCtsQueryDefinition querydefRawCts = queryMgr.newRawCtsQueryDefinition(handle);
StringBuilder batchRawCtsResults = new StringBuilder();
StringBuilder batchRawCtsFailures = new StringBuilder();

  QueryBatcher queryBatcher2 = dmManager.newQueryBatcher(querydefRawCts);
  queryBatcher2.onUrisReady(batch -> {
      for (String str : batch.getItems()) {
    	  batchRawCtsResults.append(str)
            .append('|');
      }
    })
    .onQueryFailure(throwable -> {
      System.out.println("Exceptions thrown from callback onQueryFailure for RawCtsQueryDefinition");
      throwable.printStackTrace();
      batchRawCtsFailures.append("Test has Exceptions");
    });

    JobTicket jobTicketRawCtsQ = dmManager.startJob(queryBatcher2);

...
...

@ehennum
Copy link
Contributor

ehennum commented Mar 5, 2019

The issue is that the handle doesn't specify the format.

A POST without a specified format is being treated as an application/x-www-form-urlencoded, which tries to map the body to URI parameters.

The request succeeds after adding handle.withFormat(Format.XML)

Looking into whether QueryManager defaults the format....

@ehennum
Copy link
Contributor

ehennum commented Mar 5, 2019

QueryManager defaults the format to XML. So, the internal requester should do the same.

ehennum pushed a commit that referenced this issue Mar 6, 2019
@ehennum ehennum assigned georgeajit and unassigned ehennum Mar 6, 2019
@ehennum ehennum added test and removed verify labels Mar 6, 2019
@ehennum
Copy link
Contributor

ehennum commented Mar 6, 2019

I updated this test to execute both with and without an explicit format:

com.marklogic.client.test.datamovement.QueryBatcherTest#testRawCtsQuery

@georgeajit georgeajit added ship and removed test labels Mar 26, 2019
@ehennum ehennum closed this as completed Oct 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants