2016-10-03 75 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