@Test public void testPOJOValueQueryWithCriteria() { PojoRepository<Artifact, Long> products = client.newPojoRepository(Artifact.class, Long.class); PojoPage<Artifact> p; this.loadSimplePojos(products); String[] searchOptions = { "case-sensitive", "wildcarded", "min-occurs=1" }; PojoQueryBuilder qb = products.getQueryBuilder(); String[] searchNames = { "Acme spe* *", "Widgets spe* *" }; PojoQueryDefinition qd = qb.value("name", searchOptions, 100.0, searchNames).withCriteria("Cogs 101"); JacksonHandle jh = new JacksonHandle(); products.setPageLength(5); p = products.search(qd, 1, jh); JsonNode nodePos = jh.get(); // Return 1 node - constraint2.xml assertEquals("Number of results returned incorrect in response", "1", nodePos.path("total").asText()); assertEquals("Result returned incorrect in response", "com.marklogic.client.functionaltest.Artifact/101.json", nodePos.path("results").get(0).path("uri").asText()); }
StructuredQueryDefinition strutdDef = (qb.valueConstraint("popularity", "5")).withCriteria("Vannevar"); node.path("results").get(1).path("uri").asText().contains("/structured-query/constraint4.xml")); StructuredQueryDefinition strutdDefPos = (qb.valueConstraint("popularity", "5")).withCriteria("Vannevar").withCriteria("Atlantic").withCriteria("intellectual"); StructuredQueryDefinition strutdDefNeg = (qb.valueConstraint("popularity", "5")).withCriteria("Vannevar").withCriteria("England"); strutdDef2.withCriteria("Vannevar").setCriteria("Bush");
PojoQueryDefinition qd2 = qb.value("name", searchOptions, 100.0, searchNames).withCriteria("Cogs 101"); long cnt2 = products.count(qd2); System.out.println("Count returned from PojoRepository is " + cnt2);
.withCriteria("Chittagong"); try ( PojoPage<City> page = cities.search(query, 1) ) { int numRead = 0;