Hi,

I want to use Apache Solr to perform a spatial search and then display the results list with an Openlayers map showing the location of the found nodes.

I have Apache Solr running and I also managed to build a view with location distance/proximity fields that display results on an openlayers map, but I can't figure out how to put the two together.

I really appreciate any help on this so thanks for reading

CommentFileSizeAuthor
#26 openlayers_views_map_style.patch774 bytesCitizenKane
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

tmcw’s picture

Are you using apachesolr_views? Which part are you missing exactly, if you have results showing up on a map?

Hazlitt’s picture

Hi, Thanks for responding.

No, I have used location distance/proximity exposed filter to display results on a map. The location is a UK postcode.

What I want to do is use apache solr with distance /proximity to display a map. I have an issue with spatial solr not working for UK postcodes which I need to figure out, but I don't know how to get a map of results displayed from an Apache Solr search.

I'll take a look at apachesolr_views and see if I can figure it out.

Hazlitt’s picture

Gave up on Spatial solr as I can't see how to get it to support UK postcodes.

Installed Views3 and had a good look at creating Apache Solr views which work fine, but the fields available in the views do not include the latitude and longitude fields I need to pass to Openlayers to populate a map.

I tried creating a view of type node and then adding the apache solar search as an exposed filter but it isn't listed as available so I still can't see how to get openlayers to dispay a map from an Apachesolr search.

tmcw’s picture

What is your objective? It's very unclear. Are you simply searching for nodes within a certain postcode and showing them on a map? In that case, it isn't necessary at all to have any complex search machinery, just use Geo Taxonomy.

Hazlitt’s picture

I want to use Apache Solr to search for nodes and then display a short list of results with a map that shows the geographical location of each of the search results.

If I could add the ability to search by distance/proximity that would be great, but I took a long look at spatialsolr and couldn't see how to set it up to use UK post codes.

tmcw’s picture

Status: Active » Postponed (maintainer needs more info)

Sorry, yeah, I can help you integrate Apache Solr with OpenLayers - I'm rather interested in how that works anyway, but debugging Solr itself + Spatial Solr isn't in the scope of this project, and it's hard to discern, again, what state your project is in (like, are these locations even geocoded yet?) My intuition is that unless you're dealing with serious numbers of nodes (>30,000), Solr is overkill and you can just use views filters to do the same thing. But, marking as postponed because this isn't really about OpenLayers anymore.

Hazlitt’s picture

If you can help me integrate Apache Solr with Openlayers and output search results on a map with a results list that would be great. I have tried a few different approaches and not succeeded, including trying to add support for CCK fields to Apache Solr.

The map I have working is using the location module with Openlayers and the location distance/proximity filter to display a map and list of search results.

The client is very keen on the search functionality of Apache Solr which is why I have been trying to get it to work with an Openlayers map.

tmcw’s picture

So the location module is working but you need to spot it in with Apache Solr?

Yes, the Apache Solr module is limited in many ways - I don't think that it currently includes custom fields in its schema, and it's very complex to do this correctly. But, until you have a view that is exposing lat/lon or WKT to OpenLayers, it simply isn't something that I can help with because there's too much setup and the maintainers of OpenLayers don't have enough time to deal with other modules in depth. Please post on the Apache Solr issue tracker instead.

Hazlitt’s picture

Ok, will do, thank you for your help.

tmcw’s picture

Status: Postponed (maintainer needs more info) » Closed (works as designed)

Setting as by design at this point; please open a ticket for specific OpenLayers-related support.

robertDouglass’s picture

Subscribe. I think there are a lot of people wanting to get this working. Will help connect people as I come across them.

zzolo’s picture

As @tmcw pointed out, the key is to get latitude and longitude exposed as fields from an Apache Solr Views search. In theory that is all you need to be done and a map can easily be generated with the OpenLayers Views data display plugin.

I think the problem here is that Location doesn't actually expose its lat and lon as fields in Views, though there already is a ticket for it. OpenLayers should not make up for this fact. I do want to see this a reality, but I think this module is not really what is holding things up.

cglusky’s picture

Well, I will throw in on this one...

Background
- OpenCalais returns geo results that get stored in calais_term_data_geo so I hacked on OpenCalais to expose the lat/long fields to views.
- Works great with OpenLayers http://173.165.43.49/~metanomy/map2
- Works fine with OC and Solr http://173.165.43.49/~metanomy/search/apachesolr_search/oil
- Running latest dev versions on that sandbox: OL 6.2 and Views 6.3

Error
- When I try to create a Solr View that uses the OL Views Data plugin as part of a Solr View I get: "Fatal error: Call to a member function pre_execute() on a non-object in /home/metanomy/domains/metanomy.org/public_html/sites/all/modules/apachesolr_views/apachesolr_views_query.inc on line 311"
- Have tried a Page using OL as view style with a Solr Search filter, as well as an OL Attachment to a Page that's running a Solr Search as a filter. Same results.

Big Guess
- I am wondering if this error occurs because OL needs the lat/long fields to render but those fields are not part of the Solr index?
- I am getting ready to see if I can address this by using Apache Solr Facet Builder to add lat/long as a facet, but I have my doubts.

This is all running on my sandbox and I am more than willing to allow the OL and Views folks access to play around and see what's going on. The data set is derived from Feeds module pulling in a twitter and google search; passing that to OpenCalais; and spitting it back out as required with Solr, OL and views. Just ping me if you want an account.

R,
C

cglusky’s picture

Version: 6.x-1.0-rc1 » 6.x-2.x-dev
Status: Closed (works as designed) » Active

Turns out I am running wrong schema version for Solr. Need to update that and test to see if errors go away. Setting back to active for latest 2.x-dev and will update status once I get the tests done.

tmcw’s picture

Status: Active » Closed (works as designed)

Please continue discussion here, but this is, for the OpenLayers module, out of scope. If a bug is discovered, we'll work on it, but we can't support Solr and other modules via this one. Search integration has been tested to work and is working on production with the searchlight module, and if apachesolr and other modules provide similar views-query-plugin backends, then they should work transparently with this module.

cglusky’s picture

Fair enough. Since we have several modules in play on this one, if the error does not go away once schema is updated, I will need some help determining what queue gets the issue.

cglusky’s picture

Updated solr schema to 1.9.6 and I still get the following error when I try to use OpenLayers display with Apache Solr Views integration:

"Fatal error: Call to a member function pre_execute() on a non-object in /home/metanomy/domains/metanomy.org/public_html/sites/all/modules/apachesolr_views/apachesolr_views_query.inc on line 311"

Any thoughts on best queue to move this to?

I am currently testing searchlight as it seems to cover my use case. But I am sure there are others who would like to have OpenLayers work with Apache Solr Views et al.

rhymeswithcamera’s picture

+1 subscribing

Francewhoa’s picture

+1 subscribing

tmcw’s picture

Huh? Nothing is going to happen here, as far as this module. It's compatible with Views, and the Apache Solr module, when it's correctly working, is compatible with the other end of views.

light9’s picture

subscribe

jayxdev’s picture

Hi , i made this way (with exposed filters)!
I have a list of taxonomy terms and when I select one and click to apply, corresponding nodes appear on the openlayers map !
However ,i want to have also a list of corresponding nodes title on the same page but i don't knowhow to do that !!
Cann you help me ?

jayxdev’s picture

Oki i succeed to do what i wanted !
I used content panes , views ,panels
I have an exposed filter displayed as a block!
When i select a taxonomy term , my map and my node title list is updated!
It was simple finally! :)

WoozyDuck’s picture

Component: OpenLayers Views » OL API

subscribing

mgifford’s picture

CitizenKane’s picture

I was having the same error as in #13, two years after the fact ;).

I've done some investigation and it seems it is an issue in OpenLayers Views.

In particular this code in openlayers_views_style_map.inc

 /**
   * Query - override to make sure this doesn't get run
   */
  function query() {
    $this->view->built = TRUE;
  }

The problem with this is it causes the view to not run it's build method. This is however where the pager is initialized (which in turn ends up being passed to the query plugin). When it's passed to the query plugin the pager isn't there because it was never built. From there everything explodes. I imagine that with the views default query plugin this just happens not to surface, but when using an alternate (apachesolr views for example) problems occur. I imagine this would happen with other views query plugins, but I'm not aware of any others off the top of my head.

Simply removing the above method causes the problem to be fixed. While I imagine this does incur a performance hit, I believe the behavior is more correct. I've reopened and attached a patch. Doing so for the sake of context, if it needs to be another issue please let me know.

CitizenKane’s picture

Category: support » bug
Status: Closed (works as designed) » Needs review

Updated to the newest version of Openlayers (accidentally blowing away my patch) and realized that I had failed to reopen this. I think this is now effectively a bug report as per comment #26. If there's anyone that can test this that would be great, though my patch has been working fine in production since I made it last year.

Pol’s picture

Issue summary: View changes

Is this patch ok for version 6.x ?

ken-g’s picture

Status: Needs review » Closed (outdated)