Skip to content

StructuredQueryBuild search throws exception when no results found #908

Closed
@alan-johnson

Description

@alan-johnson

So we can address your issue, please include the following:

  • Version of MarkLogic Java Client API (see Readme.txt)
    MarkLogic 8 - Java API 3.0.1, 3.0.8
    MarkLogic 9 - Java API 4.0.3, 4.0.3.1
  • Version of MarkLogic Server (see admin gui on port 8001)
    MarkLogic 8.0-3
    MarkLogic 9.0-4
  • Java version (java -version)
    java version "1.8.0_111"
  • OS and version
    MacOS, High Sierra, 10.13.3
  • Input: Some code to illustrate the problem, preferably in a state that can be independently reproduced on our end
    Structured queries throw an exception when the data queried is not found. If data is found, results are returned as expected and no exceptions are throws. I've included a .ZIP file that recreates the issue using ML9 and 4.0.3.1 of the Java Client API.

//DEFINE A QUERY MANAGER
QueryManager queryMgr = client.newQueryManager();

	//DEFINE THE STRUCTURED QUERY BUILDER AND TELL IT WHICH SEARCH OPTIONS DOCUMENT TO USE
    StructuredQueryBuilder sQB = new StructuredQueryBuilder("Unit09-Exercise3-Options");
	
	//CREATE THE STRUCTURED QUERY
	//WE WANT "AND" LOGIC:  ARTIST AND GENRE AND OTHER-TERM AND NOT SOME-OTHER-TERM
	StructuredQueryDefinition queryDef = sQB.and(
			sQB.rangeConstraint("artist", Operator.EQ, qArtist),
			sQB.rangeConstraint("genre", Operator.EQ, qGenre),
			sQB.term(qOther),
			sQB.not(sQB.term(qNot))
            );
            
	//RUN THE QUERY, RETURNING RESULTS USING A SEARCH HANDLE
	SearchHandle results = queryMgr.search(queryDef, new SearchHandle());
  • Actual output: What did you observe? What errors did you see? Can you attach the logs? (Java logs, MarkLogic logs)
    at com.marklogic.client.io.SearchHandle$SearchResponseImpl.handleResponse(SearchHandle.java:1157)
    at com.marklogic.client.io.SearchHandle$SearchResponseImpl.handleTop(SearchHandle.java:1130)
    at com.marklogic.client.io.SearchHandle$SearchResponseImpl.parse(SearchHandle.java:1098)
    at com.marklogic.client.io.SearchHandle$SearchResponseImpl.access$100(SearchHandle.java:1061)
    at com.marklogic.client.io.SearchHandle.receiveContent(SearchHandle.java:158)
    at com.marklogic.client.io.SearchHandle.receiveContent(SearchHandle.java:82)
    at com.marklogic.client.impl.OkHttpServices.search(OkHttpServices.java:2062)
    at com.marklogic.client.impl.QueryManagerImpl.search(QueryManagerImpl.java:175)
    at com.marklogic.client.impl.QueryManagerImpl.search(QueryManagerImpl.java:139)
    at com.mlu.app.App.runSearch(App.java:52)
    at com.mlu.app.App.main(App.java:26)

  • Expected output: What specifically did you expect to happen?
    Expected no results but no exceptions thrown.
    mlu-test.zip

  • Alternatives: What else have you tried, actual/expected?

Metadata

Metadata

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions