StructuredQueryDefinition t = qb.geospatial(qb.geoRegionPath(qb.pathIndex("/root/item/box"), CoordinateSystem.WGS84DOUBLE), GeospatialOperator.DISJOINT, qb.box(-40.234, 100.4634, -20.345, 140.45230) );
StructuredQueryDefinition t = qb.geospatial(qb.geoRegionPath(qb.pathIndex("/root/item/circle"), CoordinateSystem.WGS84DOUBLE), GeospatialOperator.WITHIN, qb.box(-6, 30, 100, 150) );
@Ignore public void testLinestringCrossesBox() throws KeyManagementException, NoSuchAlgorithmException, IOException, ParserConfigurationException, SAXException, XpathException, TransformerException { System.out.println("Running testLinestringCrossesBox"); QueryManager queryMgr = client.newQueryManager(); // create query def StructuredQueryBuilder qb = queryMgr.newStructuredQueryBuilder(); StructuredQueryDefinition t = qb.geospatial(qb.geoRegionPath(qb.pathIndex("/root/item/linestring"), CoordinateSystem.WGS84DOUBLE), GeospatialOperator.CROSSES, qb.box(-5.45, -76.35643, 5.35, -54.636) ); // create handle JacksonHandle resultsHandle = new JacksonHandle(); queryMgr.search(t, resultsHandle); // get the result JsonNode resultNode = resultsHandle.get(); // Should have 2 nodes returned. assertEquals("Two nodes not returned from testPolygonCoversBox method ", 2, resultNode.path("total").asInt()); }
StructuredQueryDefinition geoQuery = qb.geospatial(qb.geoPath(qb.pathIndex("/doc/g-elem-point")), qb.box(-12, -5, -11, -4)); Collection<String> nameSpaceCollection = qb.getNamespaces().getAllPrefixes(); assertEquals("getNamespace failed ", false, nameSpaceCollection.isEmpty());
@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); }
@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); }
@Test public void testTestStructuredSearchGeoBox() throws KeyManagementException, NoSuchAlgorithmException, IOException, ParserConfigurationException, SAXException, XpathException, TransformerException { System.out.println("Running testTestStructuredSearchGeoBox"); String queryOptionName = "geoConstraintOpt.xml"; DatabaseClient client = getDatabaseClient("rest-admin", "x", getConnType()); // write docs loadGeoData(); setQueryOption(client, queryOptionName); QueryManager queryMgr = client.newQueryManager(); // create query def StructuredQueryBuilder qb = queryMgr.newStructuredQueryBuilder(queryOptionName); StructuredQueryDefinition geoElementConstraintQuery = qb.geospatialConstraint("geo-elem-child", qb.box(-12, -5, -11, -4)); StructuredQueryDefinition termQuery = qb.term("karl_kara"); StructuredQueryDefinition finalAndQuery = qb.and(geoElementConstraintQuery, termQuery); // create handle DOMHandle resultsHandle = new DOMHandle(); queryMgr.search(finalAndQuery, resultsHandle); // get the result Document resultDoc = resultsHandle.get(); System.out.println("Output : " + convertXMLDocumentToString(resultDoc)); assertXpathEvaluatesTo("1", "string(//*[local-name()='result'][last()]//@*[local-name()='index'])", resultDoc); assertXpathEvaluatesTo("/geo-constraint/geo-constraint2.xml", "string(//*[local-name()='result']//@*[local-name()='uri'])", resultDoc); // release client client.release(); }
@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); }
@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); }
@Test public void testStructuredSearch2() throws IOException { QueryManager queryMgr = Common.client.newQueryManager(); EditableNamespaceContext namespaces = new EditableNamespaceContext(); namespaces.put("x", "root.org"); namespaces.put("y", "target.org"); StructuredQueryBuilder qb = new StructuredQueryBuilder(namespaces); StructuredQueryDefinition qdef = qb.geospatial( qb.geoPath(qb.pathIndex("/x:geo/y:path")), qb.box(1, 2, 3, 4)); SearchHandle results = queryMgr.search(qdef, new SearchHandle()); assertNotNull(results); MatchDocumentSummary[] summaries = results.getMatchResults(); assertTrue(summaries == null || summaries.length == 0); }
t = qb.geospatialConstraint("geo", qb.box(1, 2, 3, 4), qb.circle(0, 0, 100), qb.point(5, 6), qb.polygon(qb.point(1, 2), qb.point(2, 3), qb.point(3, 4), qb.point(4, 1))); for (String q: new String[]{t.serialize(), qb.build(t).toString()}) { qb.box(1, 2, 3, 4), qb.circle(0, 0, 100), qb.point(5, 6), qb.polygon(qb.point(1, 2), qb.point(2, 3), qb.point(3, 4), qb.point(4, 1))); for (String q: new String[]{qb.build(m).toString()}) { FragmentScope.DOCUMENTS, new String[] {"score-function=linear", "scale-factor=2.0"}, qb.box(1, 2, 3, 4), qb.circle(0, 0, 100), qb.point(5, 6), qb.polygon(qb.point(1, 2), qb.point(2, 3), qb.point(3, 4), qb.point(4, 1))); for (String q: new String[]{qb.build(m).toString()}) { qb.box(1, 2, 3, 4), qb.circle(0, 0, 100)); for (String q: new String[]{qb.build(m).toString()}) { xml = new StringInputStream(q); m = qb.geospatial( qb.geoPath(qb.pathIndex("/x:geo/y:path")), qb.box(1, 2, 3, 4));