通过 geoserver 从 Geotools 进行 solr 查询
Make a solr query from Geotools through geoserver
我来这里是因为我正在搜索(如标题中提到的)从 geotools(通过 geoserver)进行查询以从 solr 索引中获取特征。
更准确地说:
我在 geoserver 用户手册上看到我可以在 http 中像这样在 solr 上查询:
http://localhost:8080/geoserver/wfs?service=WFS&version=1.1.0&request=GetFeature
&typeName=mySolrLayer
&format="xxx"
&viewparams=q:"mySolrQuery"
这个 URL 的重要部分是我想直接从 geotools 使用的视图参数。
我已经测试过这个案例(这是我的代码的一部分):
url = new URL(
"http://localhost:8080/geoserver/wfs?request=GetCapabilities&VERSION=1.1.0";
);
Map<String, String> param = new HashMap();
params.put(WFSDataStoreFactory.URL.key, url);
param.put("viewparams","q:myquery");
Hints hints = new Hints();
hints.put(Hints.VIRTUAL_TABLE_PARAMETERS, viewParams);
query.setHints(hints);
...
featureSource.getFeatures(query);
但是在这里,它似乎不起作用,url 发送到地理服务器是一个没有 viewparams 参数的正常 "GET FEATURE" 请求。
我用 geotools-12.2 试过了; geotools-13.2 和 geotools-15-SNAPSHOT 但我没有成功通过查询,geoserver 向我发送了我数据库中的所有功能并且没有将 "viewparams" 作为参数。
我需要这样做,因为实际上查询来自另一个程序,我可以轻松地将此查询传达给项目的另一部分...
如果有人可以帮助我?
目前似乎没有办法在 GeoTool 的 WFSDatastore implementations as the GetFeature request is constructed from the URL provided by the getCapabilities document. This is as the standard 要求中执行此操作,但可能值得提出功能增强请求以允许客户端覆盖此字符串(正如 QGIS 为example) 这将允许您在基础 URL 中指定附加参数,然后根据需要将其传递给服务器。
不幸的是,WFS 模块目前存在于 Unsupported
土地上,因此除非您有资源自己解决这个问题并且 can provide a PR 实施它,否则实施它的可能性不大。
我来这里是因为我正在搜索(如标题中提到的)从 geotools(通过 geoserver)进行查询以从 solr 索引中获取特征。
更准确地说:
我在 geoserver 用户手册上看到我可以在 http 中像这样在 solr 上查询:
http://localhost:8080/geoserver/wfs?service=WFS&version=1.1.0&request=GetFeature
&typeName=mySolrLayer
&format="xxx"
&viewparams=q:"mySolrQuery"
这个 URL 的重要部分是我想直接从 geotools 使用的视图参数。
我已经测试过这个案例(这是我的代码的一部分):
url = new URL(
"http://localhost:8080/geoserver/wfs?request=GetCapabilities&VERSION=1.1.0";
);
Map<String, String> param = new HashMap();
params.put(WFSDataStoreFactory.URL.key, url);
param.put("viewparams","q:myquery");
Hints hints = new Hints();
hints.put(Hints.VIRTUAL_TABLE_PARAMETERS, viewParams);
query.setHints(hints);
...
featureSource.getFeatures(query);
但是在这里,它似乎不起作用,url 发送到地理服务器是一个没有 viewparams 参数的正常 "GET FEATURE" 请求。
我用 geotools-12.2 试过了; geotools-13.2 和 geotools-15-SNAPSHOT 但我没有成功通过查询,geoserver 向我发送了我数据库中的所有功能并且没有将 "viewparams" 作为参数。
我需要这样做,因为实际上查询来自另一个程序,我可以轻松地将此查询传达给项目的另一部分...
如果有人可以帮助我?
目前似乎没有办法在 GeoTool 的 WFSDatastore implementations as the GetFeature request is constructed from the URL provided by the getCapabilities document. This is as the standard 要求中执行此操作,但可能值得提出功能增强请求以允许客户端覆盖此字符串(正如 QGIS 为example) 这将允许您在基础 URL 中指定附加参数,然后根据需要将其传递给服务器。
不幸的是,WFS 模块目前存在于 Unsupported
土地上,因此除非您有资源自己解决这个问题并且 can provide a PR 实施它,否则实施它的可能性不大。