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

Add a RawCtsQueryDefinition to parallel RawCombinedQueryDefinition and RawStructuredQueryDefinition #720

Closed
sammefford opened this issue Apr 6, 2017 · 3 comments

Comments

@sammefford
Copy link
Contributor

It looks like you currently can use QueryManager.newCombinedQueryDefinition or newStructuredQueryDefinition and pass in a raw serialized cts query. But it's confusing to do a raw cts query that way. Therefore I propose we add RawCtsQueryDefinition and have it extend RawQueryDefinition and work just like RawCombinedQueryDefinition and RawStructuredQueryDefinition.

@sammefford
Copy link
Contributor Author

Here's an example work-around that works fine in 4.0.1:

import com.marklogic.client.DatabaseClient;
import com.marklogic.client.DatabaseClientFactory;
import com.marklogic.client.DatabaseClientFactory.DigestAuthContext;
import com.marklogic.client.io.Format;
import com.marklogic.client.io.StringHandle;
import com.marklogic.client.query.QueryManager;
import com.marklogic.client.query.RawQueryDefinition;

public class CtsQueryTest {
  public static void main(String[] args) {
    System.setProperty("org.apache.commons.logging.simplelog.log.org.apache.http.wire", "debug");
    DatabaseClient client = DatabaseClientFactory.newClient("localhost", 8000, new DigestAuthContext("admin", "admin"));
    QueryManager queryMgr = client.newQueryManager();
    RawQueryDefinition query = queryMgr.newRawCombinedQueryDefinitionAs(Format.XML,
      "<cts:word-query xmlns:cts=\"http://marklogic.com/cts\">" +
      "  <cts:text>someSearchTerm</cts:text>" +
      "</cts:word-query>");
    StringHandle results = queryMgr.search(query, new StringHandle());
    System.out.println(results.get());
  }
}

sammefford added a commit that referenced this issue May 9, 2017
…finition and RawStructuredQueryDefinition
@sammefford sammefford added test and removed fix labels May 9, 2017
@sammefford sammefford assigned georgeajit and unassigned sammefford May 9, 2017
@sammefford
Copy link
Contributor Author

sammefford commented May 9, 2017

Here are the API changes:

com.marklogic.client.io.marker.CtsQueryWriteHandle extends AbstractWriteHandle {
}

// this parallels RawStructuredQueryDefinition except
// this doesn't yet extend ValueQueryDefinition until that's implemented in the REST layer
com.marklogic.client.query.RawCtsQueryDefinition extends QueryDefinition {
  String getCriteria(String criteria)
  void setCriteria()
  RawCtsQueryDefinition withCriteria(String criteria)
  CtsQueryWriteHandle getHandle()
  void setHandle(CtsQueryWriteHandle handle)
  RawCtsQueryDefinition withHandle(CtsQueryWriteHandle handle)
}

QueryManager {
  RawCtsQueryDefinition newRawCtsQueryDefinition(CtsQueryWriteHandle handle)
  RawCtsQueryDefinition newRawCtsQueryDefinition(CtsQueryWriteHandle handle, String optionsName)
  RawCtsQueryDefinition newRawCtsQueryDefinitionAs(Format format, Object query)
  RawCtsQueryDefinition newRawCtsQueryDefinitionAs(Format format, Object query, String optionsName)
}

Add CtsQueryWriteHandle marker interface to these classes:

BytesHandle
DOMHandle
FileHandle
InputSourceHandle
InputStreamHandle
JacksonDatabindHandle
JacksonParserHandle
OutputStreamHandle
ReaderHandle
SourceHandle
StringHandle
XMLEventReaderHandle
XMLStreamReaderHandle

georgeajit added a commit that referenced this issue May 23, 2017
@georgeajit georgeajit added ship and removed test labels May 23, 2017
@kcoleman-marklogic
Copy link
Contributor

Values query support is in now.

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

4 participants