Closed nathan-schmidt-viget closed 1 year ago
@nathan-schmidt-viget can you check your error logs for any errors that happened around that time? It sounds like a PHP error is occurring and preventing the request from completing
@tw2113 I looked at the log for my ddev and found that $custom_ranking
was being set to an array.
If I change $custom_ranking
to $custom_ranking[]
I get the error FastCGI sent in stderr: "PHP message: PHP Warning: Undefined array key "aroundLatLngViaIP"
Can you provide the entire snippet of code you're using, including the add_filter and callback parts? I would like to check and confirm some things.
Also if this is part of the Personalization API/areas of Algolia, then I don't have a personal plan high enough to access/test much.
That said, the setting is a true/false value so I'm not quite sure why you're using array_unshift and whatnot. Lastly, have you confirmed that you have that index already in the incoming settings? Otherwise, perhaps just set it, and make sure to do boolean true
and not string 'true'
since I believe they're a little picky on parameter types.
Thanks @tw2113, it is not part of the Algolia personalization API. But a parameter under GeoSearch
Ya I had the whole array_unshift and whatnot as that is what I saw in the plugin docs Originally had $settings['aroundLatLngViaIP'][] = true;
which gives me the same error Invalid object attributes: aroundLatLngViaIP
Here is my post_settings
function that is called by two different post types.
/* algoliaSync.php */
/**
* post_settings function
*
* @param array $settings
* @param array $postFields
* @return $settings
*/
function post_settings( array $settings, $postType, $postFields) {
// Eligible post meta fields.
foreach ( $postFields as $field ) {
$settings['attributesToIndex'][] = 'unordered('.$field.')';
}
if ($postType == 'provider'){
$settings['attributesForFaceting'][] = 'services.post_title';
$settings['attributesForFaceting'][] = 'locations.post_title';
$settings['hitsPerPage'][] = 10;
}
if ($postType == 'location'){
$settings['attributesForFaceting'][] = 'services.post_title';
$settings['hitsPerPage'][] = 10;
$settings['aroundLatLngViaIP'][] = true;
}
return $settings;
}
Thanks @tw2113, it is not part of the Algolia personalization API. But a parameter under GeoSearch
Noted on that part, I asked largely because I can't find where the setting is found at in the dashboard that I see when I log in to my free tier account. What I mean by this is where in the "configuration tab" this aroundLatLngViaIP
would be set at, if at all. That's where this settings filter is pulling in data to configure by.
aroundLatLngViaIP
is honestly feeling like a configuration that's set as part of the query execution itself. The problem with that is that I'm not seeing where in our current templates, we would include that. I thought the "configure" widget that's available would maybe help, but I think I broke things more than implemented correct.
The only place I see it in Algolia is under Add Query Parameter > Geo-Search. But you could be right that it is a part of the props that can be passed in on the frontend.
Did you ever figure out a solution for this @nathan-schmidt-viget ?
@tw2113 Yes, the solution is in Algolia by using Configure.
<InstantSearch indexName={index}>
<Configure aroundLatLngViaIP="true" aroundRadius="all" />
</InstantSearch>
Describe the bug I need to set a custom post setting for
aroundLatLngViaIP
. In myadd_filter( 'algolia_posts_index_settings', 'service_settings' );
But when I try and sync the settings I getAn error occurred
To Reproduce Place this in function for custom index setting.
Expected behavior Add
aroundLatLngViaIP
to the api parameters - https://www.algolia.com/doc/api-reference/api-parameters/aroundLatLngViaIP/?client=php