假设我使用coords
生成了新生成的solr核心$bin/solr generate -c coords
。
然后我使用JST库将fieldtype“location_rpt”更改为可用于笛卡尔/几何数据而不是地理数据:
<fieldType name="location_rpt" class="solr.SpatialRecursivePrefixTreeFieldType" maxDistErr="0.001" spatialContextFactory="org.locationtech.spatial4j.context.jts.JtsSpatialContextFactory" validationRule="repairBuffer0" distErrPct="0.025" distanceUnits="kilometers" autoIndex="true"/>
然后我通过使用此类型的Solr Admin UI向我的架构添加了一个字段,用于保存存储为WKT-Strings(POINT(X Y)
)的点
我创建了三个示例文档:
{
"responseHeader":{
"status":0,
"QTime":0,
"params":{
"q":"*:*",
"indent":"on",
"fl":"coords",
"wt":"json",
"_":"1485793578398"}},
"response":{"numFound":3,"start":0,"docs":[
{
"coords":"POINT(0 0)"},
{
"coords":"POINT(1 1)"},
{
"coords":"POINT(3 3)"}]
}}
现在我想基于边界框过滤结果,以便不应该从查询中返回第三个点(3 3),但其他的应该是。
从documentation我尝试将示例字符串修改为我的需要:
/select?d=1&fl=coords&fq={!bbox sfield=coords}&indent=on&pt=1,1&q=*:*&wt=json
这只返回一个点(POINT(1 1)
),我觉得这不是结果,而是直接基于查询中的pt
参数。
如何修改查询以在我的边界框中查询点?
答案 0 :(得分:0)
对于任何有兴趣的人 - 我找到了解决方案:
fq=coords:[0,0 TO 2,2]
所以完整的URL编码查询将是:
select?fq=coords:[0.0,0%20TO%202,2]&indent=on&q=*:*&wt=json