2016-10-03 143 views
0

我正在运行Solr 5.4(在Ubuntu服务器上)并从MySQL索引。它非常适合搜索和刻面,但现在我想实现地理空间过滤。在管理界面我跑,Solr geofilt返回所有结果

http://mysite:8983/solr/core/select?q=*%3A*&wt=json&indent=true&defType=edismax&spatial=true&pt=44.8859987%2C-93.0833396&sfield=org_loc&d=50 

模式:

<field name="org_loc" type="location" indexed="true" stored="true"/> 
<fieldType name="location" class="solr.LatLonType" subFieldSuffix="_coordinate"/> 

响应:

{ 
    "responseHeader":{ 
    "status":0, 
    "QTime":13, 
    "params":{ 
     "lowercaseOperators":"true", 
     "d":"50", 
     "spatial":"true", 
     "indent":"true", 
     "q":"*:*", 
     "sfield":"org_loc", 
     "pt":"44.8859987,-93.0833396", 
     "stopwords":"true", 
     "wt":"json", 
     "defType":"edismax"}}, 
    "response":{"numFound":21,"start":0,"docs":[ 
     "org_name": "..." 
     "org_loc":"44.8259987,-93.0813396", 
     ...etc. 

的问题是,它返回每次21的21条记录,不管d的。

+0

可能是你只有21条记录与匹配标准是什么?你检查过其他输入吗? –

+0

该数据库拥有21个用于测试的虚假数据的总记录。无论pt或d如何,它都会返回全部21条记录。 – SM0827

+0

d是径向距离,通常以公里为单位,请将此值增加到100并测试一次 –

回答

1

geofilt必须使用fq参数需要明确,查询的这部分丢失:

&fq={!geofilt} 
+0

这很有效!我之前尝试过多次geofilt,甚至直接从该手册中粘贴此行:&q = *:*&fq = {!geofilt sfield = org_loc}&pt = 44.8859987,-93.0833396&d = 50,但它不起作用。奇怪的是,当我在管理用户界面的fq参数中输入{!geofilt}时,它确实有效,它会生成以下代码:&fq = {!geofilt}&spatial = true&pt = 44.8659987%2C-93.0823396&sfield = org_loc&d = 500(加上其他相关参数)。感谢您指点我正确的方向! – SM0827