-1

I'm trying to create a search page with Search API Solr, Search API location and a Geolocation field.

I've got my view, and my lat/lng fields are correctly indexed. E.g. I've selected these fields for my view

Content datasource: my_title_field (indexed field)
Content datasource: my_geo_field
Content datasource: my_geo_field (distance) (indexed field)
Content datasource: my_geo_field (indexed field)

and I'm getting results like this:

foo_title
47.4051909, 10.2867823
47.4051909, 10.2867823

The (distance) version of the geolocation field is always empty.

As soon as I add a filter to my_geo_field, I incorrectly do not get any results:

geo distance filter config

The query seems to be correctly:

    
Index: cms
Keys: NULL
Options: array (
    'search_api_view' => 'object (Drupal\\views\\ViewExecutable)',
    'search_api_location' => 
    array (
      0 => 
      array (
        'field' => 'field_geo',
        'lat' => '47.4051909',
        'lon' => '10.2867823',
        'radius' => 100,
      ),
    ),
    'search_api_base_path' => 'testsuche',
  )

but the results are empty, no matter which filter settings.

I've also tried the "Boundary" filter from Geolocation module, it also doesn't work with boundary lat/lng pairs.

Questions:

What is the difference between the normal my_geo_field and the my_geo_field (indexed field) when selecting fields to display? Which one should I Use?

What is the purpose of my_geo_field (distance) (indexed field)? It does not have any content, it is not available in the filters section of the view, it does not have a configuration for the remote point to calculate the distance... it doesn't make any sense and it is really confusing me.

And finally and most important: Which settings do I need to make the filter working?

Has anybody managed to make a working proximity filter with Search API or is it just broken?

0

Geolocation indexing is broken with Search API v1.16+ and will be fixed with issue 3157397

If you manually want to check the index on the Solr server, be sure to check the right fields: Spatial fields from Search API Location have the prefix locs_, e.g. if your Search API field name is field_geo, the Solr field name is locs_gield_geo

If you have any other lat or lng fields in the Solr index, those are NOT spatial fields and can not be used with Search API Location. E.g. I had Solr fields like fts_lat and fts_lng with correct geo data, but those were decimal number values, which cannot be used for proximity queries.

Also be careful with pseudo-debugging by rendering the raw geofield values as a field in your Drupal View. Just because Views is able do render the correct values, it does not necessarily mean that those values are originating from the Solr server. I made the wrong assumption when Views is rendering them, they had to be correctly indexed by Solr. But obvisouly those values were coming from the local SQL database, good enough for rendering, but not good enough for filtering or sorting.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.