Reputation: 1
Following is the code snippet for reference. I have 3 questions,
1) How to view the query that is framed in the following code to be displayed in the log? In the Log it is displayed as Junk value.
2) Once the JAVA API is trigger can we see the query that is passed in the Marklogic Logs? This can help why our wildcarded search is not working with required arguments.
3) The "wildcarded" / "exact" search options are not working / do data returned through JAVA API calls. But through Xquery from Query console data is returned.
Code Snippet:
String[] options = new String[]{"case-insensitive"};
// BUILD query
StructuredQueryDefinition query = sqb.and(sqb.value(sqb.jsonProperty(DataConstants.DOMAIN), FragmentScope.DOCUMENTS,options,9.0,Domain.Provider.name()));
query = sqb.and(sqb.value(sqb.jsonProperty(DataConstants.subDomain), FragmentScope.DOCUMENTS,options,9.0,chRequest.getDomain()));
Using exact option
options = new String []{"exact"};
query = sqb.and(query,sqb.value(sqb.jsonProperty(field.getField()), FragmentScope.DOCUMENTS,options,9.0,field.getFieldValue().get(0)));
Using wildcarded option
options = new String []{"wildcarded"};
query = sqb.and(query,sqb.value(sqb.jsonProperty(field.getField()), FragmentScope.DOCUMENTS,options,9.0,field.getFieldValue().get(0)+"*"));
System.out.println("----query>>.-----"+query);
……
……
StructuredQueryBuilder sqb = queryManager.newStructuredQueryBuilder();
StructuredQueryDefinition criteria = getQueryDefinitionCriteria(cashRequest, sqb);
SearchHandle searchHandle = queryManager.search(sqb.and(criteria), new SearchHandle(), pageNumber);
GSONHandle handle = new GSONHandle();
MatchDocumentSummary summaryArr[] = searchHandle.getMatchResults();
System.out.println("summaryArr[] >>> "+summaryArr);
Sample Log : ----query>>.-----com.marklogic.client.query.StructuredQueryBuilder$AndQuery***@247d44b4*** summaryArr[] >>> [Lcom.marklogic.client.query.MatchDocumentSummary;@f3e6876 summaryArr[].length >>> 50
Upvotes: 0
Views: 324
Reputation: 2475
How to view the query that is framed in the following code to be displayed in the log?
Call query.serialize()
Once the JAVA API is trigger can we see the query that is passed in the Marklogic Logs?
See Debugging /search Queries With Logging. Also consider using a network snooping tool like wireshark to see the network communication. You can also set the Java system property com.marklogic.client.okhttp.httplogginginterceptor.level
to body
to see most REST (HTTP) requests & responses in the Java STDOUT. Just beware that you can't use that with streaming handles (like InputStreamHandle). Luckily, you're not using one of those here.
The "wildcarded" / "exact" search options are not working / do data returned through JAVA API calls. But through Xquery from Query console data is returned.
It looks like data is returned or you wouldn't see in your output that summaryArr[].length >>> 50
. In any case, I assume you mean the wrong data is returned.
Without more details it's hard to help troubleshoot. We don't know what your getQueryDefinitionCriteria
method does. And we don't know what code you're running in qconsole. Hopefully the above debugging options will help you track down the issue. If not, please share with us your code for query console and your final generated structured query (that you get with the debugging calls above).
Upvotes: 2