@Ignore public void testFloatPrecisionCoordinateSystem() { QueryManager queryMgr = Common.client.newQueryManager(); StructuredQueryBuilder qb = new StructuredQueryBuilder(); String options[] = new String[1]; options[0] = "coordinate-system=wgs84"; StructuredQueryDefinition qdef; qdef = qb.geospatial(qb.geoElementPair(qb.element("point"), qb.element("lat"), qb.element("lon")), null, options, qb.box(0, 0, 10, 10)); SearchHandle results = queryMgr.search(qdef, new SearchHandle()); MatchDocumentSummary[] summaries = results.getMatchResults(); assertEquals(2, summaries.length); }
StructuredQueryDefinition t1 = qb.value(qb.elementAttribute(qb.element(new QName("http://cloudbank.com", "price")), qb.attribute("amt")), FragmentScope.DOCUMENTS, options, 3.0, "123.45");
@Ignore public void testDoublePrecisionCoordinateSystem() { QueryManager queryMgr = Common.client.newQueryManager(); StructuredQueryBuilder qb = new StructuredQueryBuilder(); String options[] = new String[1]; options[0] = "coordinate-system=wgs84/double"; StructuredQueryDefinition qdef; qdef = qb.geospatial(qb.geoElementPair(qb.element("point"), qb.element("lat"), qb.element("lon")), null, options, qb.box(0, 0, 10, 10)); SearchHandle results = queryMgr.search(qdef, new SearchHandle()); MatchDocumentSummary[] summaries = results.getMatchResults(); assertEquals(1, summaries.length); }
StructuredQueryDefinition t = qb.word(qb.elementAttribute(qb.element(new QName("http://cloudbank.com", "price")), qb.attribute("amt")), FragmentScope.DOCUMENTS, options, .025, "123.45");
@Ignore public void testFloatPrecision() { QueryManager queryMgr = Common.client.newQueryManager(); StructuredQueryBuilder qb = new StructuredQueryBuilder(); String options[] = new String[1]; options[0] = "precision=float"; StructuredQueryDefinition qdef; qdef = qb.geospatial(qb.geoElementPair(qb.element("point"), qb.element("lat"), qb.element("lon")), null, options, qb.box(0, 0, 10, 10)); SearchHandle results = queryMgr.search(qdef, new SearchHandle()); MatchDocumentSummary[] summaries = results.getMatchResults(); assertEquals(2, summaries.length); }
StructuredQueryDefinition t = qb.value(qb.elementAttribute(qb.element(new QName("http://cloudbank.com", "price")), qb.attribute("amt")), "0.1");
@Ignore public void testDoublePrecision() { QueryManager queryMgr = Common.client.newQueryManager(); StructuredQueryBuilder qb = new StructuredQueryBuilder(); String options[] = new String[1]; options[0] = "precision=double"; StructuredQueryDefinition qdef; qdef = qb.geospatial(qb.geoElementPair(qb.element("point"), qb.element("lat"), qb.element("lon")), null, options, qb.box(0, 0, 10, 10)); SearchHandle results = queryMgr.search(qdef, new SearchHandle()); MatchDocumentSummary[] summaries = results.getMatchResults(); assertEquals(1, summaries.length); }
private RawStructuredQueryDefinition allButCollectors() { StructuredQueryBuilder sqb = jobClient.newQueryManager().newStructuredQueryBuilder(); RawStructuredQueryDefinition allButCollectors = sqb.build( sqb.and( sqb.containerQuery(sqb.element("trace"), sqb.not(sqb.value(sqb.jsonProperty("label"), "collector"))))); return allButCollectors; }
batcher = dmm.newQueryBatcher(sqb.value(sqb.element(new QName("jobId")), jobIds));
@Test public void test105Searches() throws IOException { QueryManager queryMgr = Common.client.newQueryManager(); StructuredQueryBuilder qb = queryMgr.newStructuredQueryBuilder(); for (int i=0;i<105;i++) { for (QueryDefinition t : new QueryDefinition[] { qb.term("leaf3"), qb.build(qb.value(qb.element("leaf"), "leaf3")) }) { JacksonHandle results = queryMgr.search(t, new JacksonHandle()); assertNotNull(results); JsonNode jsonResults =results.get(); @SuppressWarnings("unused") String resultString = results.getMapper().writeValueAsString(jsonResults); // ignore. } } }
StructuredQueryDefinition t = qb.word(qb.element("id"), "0026");
@Test public void testBug22037() throws KeyManagementException, NoSuchAlgorithmException, IOException, ParserConfigurationException, SAXException, XpathException, TransformerException { System.out.println("Running testBug22037"); String[] filenames = { "constraint1.xml", "constraint2.xml", "constraint3.xml", "constraint4.xml", "constraint5.xml" }; String queryOptionName = "rangeConstraintIntOpt.xml"; DatabaseClient client = getDatabaseClient("rest-admin", "x", getConnType()); // write docs for (String filename : filenames) { writeDocumentUsingInputStreamHandle(client, filename, "/range-constraint/", "XML"); } setQueryOption(client, queryOptionName); QueryManager queryMgr = client.newQueryManager(); StructuredQueryBuilder qb = queryMgr.newStructuredQueryBuilder(queryOptionName); StructuredQueryDefinition rangeQuery = qb.range(qb.element("popularity"), "xs:int", Operator.GE, 4); // create handle DOMHandle resultsHandle = new DOMHandle(); queryMgr.search(rangeQuery, resultsHandle); // get the result Document resultDoc = resultsHandle.get(); // System.out.println(convertXMLDocumentToString(resultDoc)); assertXpathEvaluatesTo("4", "string(//*[local-name()='result'][last()]//@*[local-name()='index'])", resultDoc); // release client client.release(); }
@Test public void testStructuredSearch1() throws IOException { QueryManager queryMgr = Common.client.newQueryManager(); StructuredQueryBuilder qb = queryMgr.newStructuredQueryBuilder(); for (QueryDefinition t:new QueryDefinition[]{ qb.term("leaf3"), qb.build(qb.value(qb.element("leaf"), "leaf3")) }) { MatchDocumentSummary summary = queryMgr.findOne(t); assertNotNull(summary); GenericDocumentManager docMgr = Common.client.newDocumentManager(); assertNotNull("Document exists", docMgr.exists(summary.getUri())); } }
StructuredQueryDefinition t = qb.range(qb.element("popularity"), "xs:integer", collation, Operator.GE, 4);
StructuredQueryDefinition t = qb.range(qb.element("popularity"), "xs:integer", collation, FragmentScope.DOCUMENTS, Operator.GT, 4);
String[] options = { "uncached", "min-occurs=2" }; String collation = "http://marklogic.com/collation/en"; StructuredQueryDefinition t = qb.range(qb.element("popularity"), "xs:integer", collation, options, Operator.LT, 4);
String[] options = { "uncached", "min-occurs=2" }; StructuredQueryDefinition t = qb.range(qb.element("popularity"), "xs:integer", collation, FragmentScope.DOCUMENTS, options, Operator.NE, 4);
StructuredQueryDefinition t = qb.range(qb.element("popularity"), "xs:integer", Operator.GE, 4);
StructuredQueryDefinition t = qb.range(qb.element("popularity"), "xs:integer", options, Operator.LE, 4);
@Test public void testStructuredSearch() throws IOException { QueryManager queryMgr = Common.client.newQueryManager(); StructuredQueryBuilder qb = queryMgr.newStructuredQueryBuilder(); for (QueryDefinition t:new QueryDefinition[]{ qb.term("leaf3"), qb.build(qb.value(qb.element("leaf"), "leaf3")) }) { SearchHandle results = queryMgr.search(t, new SearchHandle()); assertNotNull(results); assertFalse(results.getMetrics().getTotalTime() == -1); MatchDocumentSummary[] summaries = results.getMatchResults(); assertNotNull(summaries); assertEquals("expected 1 result", 1, summaries.length); for (MatchDocumentSummary summary : summaries) { MatchLocation[] locations = summary.getMatchLocations(); assertEquals("expected 1 match location", 1, locations.length); for (MatchLocation location : locations) { assertNotNull(location.getAllSnippetText()); } } } }