Solr에서 공간 검색을 시도하고 있습니다. 다음Solr에서 공간 검색이 작동하는지 확인하는 방법
<fieldType name="location" class="solr.LatLonType" subFieldSuffix="_coordinate"/>
<dynamicField name="*_coordinate" type="tdouble" indexed="true" stored="true"/>
<field name="location" type="location" indexed="true" stored="true"/>
<field name="location_0_coordinate" type="double" indexed="true" stored="true"/>
<field name="location_1_coordinate" type="double" indexed="true" stored="true"/>
내가 SOLR에서 문서 업데이트 할 서비스를 다시 시작 :
$local_select = 'http://localhost:8080/solr/select?q=ss_type:(business%20OR%20user%20OR%20blog)&wt=json';
$url = $local_select;
$data = file_get_contents($url);
$r_data = json_decode($data, true);
$docs = $r_data['response']['docs'];
if(!empty($docs)){
foreach($docs as $doc){
if(!empty($doc['tm_field_business_address:postal_code'][0])){
$postal_code = urlencode($doc['tm_field_business_address:postal_code'][0]);
$api = 'http://maps.googleapis.com/maps/api/geocode/json?address=' . $postal_code . '&sensor=false';
$api_results = file_get_contents($api);
$data = json_decode($api_results, true);
if($data['status'] == 'OK'){
$location = $data['results'][0]['geometry']['location'];
unset($doc['_version_']);
$doc['location_0_coordinate'] = $location['lat'];
$doc['location_1_coordinate'] = $location['lng'];
$new_docs[] = $doc;
}
}
}
}
$local_update = 'http://localhost:8080/solr/update/json';
$local_commit = 'http://localhost:8080/solr/update?commit=true';
//update the solr index
if(!empty($new_docs)){
$json_doc = json_encode($new_docs);
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_RETURNTRANSFER => 1,
CURLOPT_HTTPHEADER => array("Content-type:application/json"),
CURLOPT_URL => $local_update,
CURLOPT_POST => 1,
CURLOPT_POSTFIELDS => $json_doc,
));
$update_response = curl_exec($curl);
curl_close($curl);
//commit the changes
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => $local_commit
));
$commit_response = curl_exec($curl);
}
을 내가했던 것은 서비스를 중지 한 후 다음을 포함하는 collection1
에 대한 schema.xml
파일 업데이트 컬 응답이 좋았으며이 쿼리를 사용하여 결과를 확인할 때 다음과 같이 나타났습니다.
http://localhost:8080/solr/select?q=ss_type:(business%20OR%20user%20OR%20blog)
결과가
<double name="location_0_coordinate">49.9641523</double>
<double name="location_1_coordinate">10.1378365</double>
이제 내 문제는 정말로 제대로 설정 한 것입니까? 그리고 네, 무엇을 나는 그것 정말 반환 뭔가 한 번 나는 아래와 같은 공간 쿼리를 사용하는지 확인하는 데 사용할 수있는 쿼리 될 것입니다 경우 : 여기
http://localhost:8080/solr/select/?q=ss_type:(business%20OR%20user%20OR%20blog)&fq={!geofilt}&sfield=location&pt=49.9641523,10.1378365&d=0
내 주요 문제 것은 정말하지 알고있다 Solr 인덱스에 이미 존재하는 레코드를 리턴하기 위해 참조 포인트를 제공 할 대상.
49.9641523,10.1378365
가 무슨 좌표를 가지고있는 특정 레코드를 반환 공간 쿼리 될 것입니다 :
그래서 예를 들어 나는 지수의 다음 좌표가있는 경우. 나는 d=0
를 사용하려하지만 아무것도 반환되지 않습니다 :
<response>
<result name="response" numFound="0" start="0"/>
</response>
어떤 아이디어? 미리 감사드립니다.
이렇게 :'$ doc [ 'location_coordinate'] = $ location [ 'lat']. ','. $ location [ 'lng']'? – user225269
입력란에 \ "51.3223777, -0.1358427 \" ","code ": 400}을 입력하면 위의 작업을 수행 할 때 오류가 발생합니다. 'Error adding field'location_coordinate '='51.3223777, -0.1358427 'msg = } ' – user225269
필드 유형은'location'이어야합니다 – Stanley