Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    That tutorial looks like it should all still work, and we have similar example code at our post found at https://webdevstudios.com/2021/02/09/wp-search-with-algolia/

    One thing to keep in mind is that simply adding and saving the code isn’t going to be the only steps needed. You’ll also need to do a re-index of your content, whether it be saving individual posts or doing a bulk re-index with the buttons on the Algolia settings pages.

    That will push the newly intended content into your Algolia indices for use going forward.

    Thread Starter theblueli

    (@theblueli)

    Hi… In the end, the snippet from the algolia example does work…
    But this is stupid. We can’t use the bulk button ‘Re-index search page records’ after adding the snippet. Instead, I have to go autocomplete section find my post type ‘product’ and reindex from there.
    Now I can see the ACF data is indexed from the Algolia dashboard…
    It seems the bulk reindex button won’t add a new attribute, but once the attribute is added via the reindex button from autocomplete section. bulk reindex button able to update those attribute

    I have also added a filter like this algolia_posts_product_index_settings
    But it is not searchable, I can see the value from the Algolia dashboard, but when searching the keyword. It shows nothing.
    I will continue tomorrow.. exhausted..

    • This reply was modified 2 years, 7 months ago by theblueli.
    Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    Regarding the re-index, yeah that sounds about right where the searchable index kind of has its own bulk spot for one button. However the Autocomplete indexes in Algolia are separated out and you have to click the individual re-index button on the Autocomplete settings page.

    Regarding the code snippets, note that the example from Darren at https://webdevstudios.com/2021/02/09/wp-search-with-algolia/#indexing-custom-fields includes a foreach on the array of fields to fetch.

    You’d need to modify your first example to be closer to:

    $fields = [
    	'field_1',
    	'field_2',
    	'field_3',
    	'field_4',
    ];
    
    foreach( $fields as $field ) {
    	$data = get_field( $field, $post->ID );
    	if ( ! empty( $data )  ) {
    		$attributes[ $field ] = $data;
    	}
    }
    

    Regarding the searchability aspect, which I assume you’re referring to https://community.algolia.com/wordpress/advanced-custom-fields.html#make-custom-fields-searchable for, you would need to click the “Push settings” buttons to get that information known to your Algolia instance. That information can also be configured in the Algolia Dashboard, if preferring a UI for it.

    Thread Starter theblueli

    (@theblueli)

    Yes the variable should work… Later I found that I made a mistake so I deleted my content @@
    So it is the Push settings button… I wondered what it does. Now It is all working finally. Thanks!! Orz

    Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    Welcome! Let us know if you need anything else.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘How do you index ACF fields?’ is closed to new replies.