Posted by Anonymous on March 28, 2010 at 7:07pm
Hi,
Has anyone managed to display the output of a solr search on a map? Using either gmap, openlayers, etc.
Also has anyone got spatial search / local search working with UK postcodes?
Been trying for a week now with no success - can get core drupal search + facets working with proximity and map output but solr is so much better!
TIA
Comments
Solr search results on view/map
I think I can help.
For the map you need a view with a block diplay (please ask if you need more details about gmap maps).
On how to display the output of the solr search on the map:
- in the map view, add argument Node: NID
- configure this argument:
choose Provide default argument
Default argument type: PHP code
put this PHP code:
$response = apachesolr_static_response_cache();
$docs = $response->response->docs;
$nids = array();
if (!empty($docs)) {
foreach( $docs as $doc )
$nids[] = $doc->nid;
}
$nidList = implode( ",", $nids );
return $nidList;
Now the view will display the nodes that the apache solr search returns.
Hi! How do you do the
Hi!
How do you do the proximity search? With solr?
There is localsolr plugin
There is localsolr plugin (drupal.org/project/localsolr). It was a start. Solr 1.5 has spatial searching in it: http://drupal.org/node/685794
It is very doable, just going to require work.
Yeah I know about localsolr
Yeah I know about localsolr plugin.
But I'm curious about stevepurkiss saying "Been trying for a week now with no success - can get core drupal search + facets working with proximity and map output but solr is so much better!"
So for the moment stevepurkiss don't use solr for proximity search... or I don't understand his sentence.
stevepurkiss doesn't...
Nope, stevepurkiss doesn't use solr for proximity searching, but would very much like to. I believe there's two issues with this for my situation in particular - one is the proximity searching itself, the other is the postcode issue, being in the UK as I am...
UK Postcode
UK postcodes aren't to bad you can either pay for a db of the codes or you can use the google maps service. If you have a look around in the location module you will find this function google_geocode_location which allows you to take in a postcode and output lat and lon co-ordinates
On the Solr side it is the case of either waiting for 1.5 to be released or using the current trunk
I use
I use http://drupal.org/project/geo and the proximity search work great with views.
But now I have another project and need full text search with proximity search... So I try to integrate geo (I's easy and I don't like location) with solr. I post certainly a patch next week.
That would be great!
Thanks, and thanks to all who've replied with help on this - I was tearing my hair out ;)
Searching by proximity, keyword, node type, and taxonomy?
I'm new to this most excellent community and I'm hoping for some guidance. I'm trying to accomplish something along the lines of this topic, but perhaps slightly different (and not necessarily with solr).
My goal is to allow a user to filter their search by proximity, keyword, node type, and taxonomy term(s).
Has anyone accomplished this or have ideas for how to accomplish this?
So far, I followed directions (http://drupal.org/node/359463) to be able to create a view (with location module/u.s. zip codes copied to the database) that allows a user to enter a proximity for a zip code, keywords in the title field, node type and get successful results. Unfortunately when I try to filter for each of those things (proximity, node type, keywords in title) and add in taxonomy terms, the module crashes. It seems clear that attempting to filter by taxonomy terms is what's causing it to crash.
Here's the error message I get:
"user warning: Unknown column 'location.vid' in 'IN/ALL/ANY subquery' query: SELECT location.lid AS lid, 'Unknown' AS location_distance, node.title AS node_title, node.nid AS node_nid FROM location location LEFT JOIN location_instance location_instance ON location.lid = location_instance.lid LEFT JOIN node node ON location_instance.vid = node.vid WHERE (0) AND (location.vid IN ( SELECT tn.vid FROM term_node tn WHERE tn.tid = 0 )) AND (node.status <> 0) LIMIT 0, 10 in /home/website/public_html/modules/views/includes/view.inc on line 771."
Any thoughts on this or on how to remedy this problem (or achieve the goal of a search filtered by proximity, keyword, node type AND taxonomy term in another way) would be absolutely fantastic.
Thank you all for your amazing work!
Mapping Solr Search Results For Drupal 7
Hi all,
I tried the code provided by cfaredo -
$response = apachesolr_static_response_cache();
$docs = $response->response->docs;
$nids = array();
if (!empty($docs)) {
foreach( $docs as $doc )
$nids[] = $doc->nid;
}
$nidList = implode( ",", $nids );
return $nidList;
In drupal 7 but I get errors. My php skills are pretty basic, can anyone please suggest a modification? I understand there have been changes to apachesolr_static_response_cache()?
7 apachesolr_static_response_cache($searcher, $response = NULL)
6 apachesolr_static_response_cache($response = NULL, $namespace = 'apachesolr_search')
so how to I substitute the above code for Drupal 7?
Any help would be greatly appreciated.
Thanks!