After upgrading Search API module from 8.x-1.15 to 8.x-1.16 - on my site becomes broken indexing of Spatial (rpt type, or location) field types based on search_api_location module (this module version is not changed) - they becomes empty.
The problem is with Geolocation field type, Geofield field types works well
How to repoduce:
1. Install search_api=8.x-1.15, search_api_location= 8.x-1.0-alpha1, search_api_solr=3.8.0, geolocation=8.x-3.2
2. Create some entity with search_api_location field type, fill any coordinates in it, eg machine name field_location with value -73.138260 40.792240.
3. Make Search API index of this entity with rpt (Spatial Recursive Prefix Tree) type of index for search_api_location field.
4. Lookup at indexed data, you will see that this field is indexed normally, index contains field field_location with value [-73.138260, 40.792240].
5. Update search_api from 8.x-1.15 to 8.x-1.16 and reindex this entity, you will see that field_location field disappear from index.
Downgrading to 8.x-1.15 solve this issue.
| Comment | File | Size | Author |
|---|---|---|---|
| #5 | search_api-fix_gelolocation-3157397-5.patch | 668 bytes | murz |
| #3 | search_api-fix_gelolocation-3157397-3.patch | 589 bytes | murz |
Comments
Comment #2
murzThe source of problem is in this part of code:
search_api/src/Utility/FieldsHelper.php- functionextractFieldValues()geolocation field type provide 'value' as $main_property_name, but in $values - 'value' key is missing, here is $values contents:
Previous version of this code from 1.15 is:
that works well with this field type.
Comment #3
murzQuick solution is replace:
with old logic, like this:
because only with
getValue();field returns 'value' key, that act as$main_property_name, because it is not stored in database, but calculated dynamically.After proposed changes - all becomes work right. Patch is attached
Can anybody lookup - is this right way to fix described issue?
Comment #4
murzComment #5
murzI investigate deeper and seems found better solution: for
geolocationfield type thevalueproperty is computed, butfunction getProperties($include_computed = FALSE)don't include computed properties by default.So simply enabling
$include_computedsolve the issue too, so I change line:to
Patch is attached.
Comment #6
murzComment #7
murzComment #8
drunken monkeyThanks a lot for reporting this problem!
You’re right, your latest solution in #5 looks really good. It also shouldn’t really break anything – worst case, it will slow down some sites a bit if they contain complex computed properties. (Don’t know if those are very common, though – I don’t know of any.)
The only issue I have with the patch that, in Drupal,
TRUEshould always be uppercase. (See also the “coding standards message” in the test bot results.)Otherwise, I think this looks great, so even at the risk of getting complaints about decreased performance (though I hope not): committed.
Thanks again!
Comment #11
hudriPatch #5 worked for me with Search API v1.17 and Geolocation v3.2