Frequently Asked Questions - WebDevStudios/wp-search-with-algolia GitHub Wiki

Frequently Asked Questions

I have more records than I have posts, is that normal?

This is intentional and allows you to fully leverage the Algolia engine.

The plugin takes care of the splitting for you and makes sure that your articles are fully indexed regardless of their size. This means that even if your article is huge and you are searching for a word that is at the very bottom, you will have it as part of the suggested articles.

Is it possible to disable post splitting?

Yes, you can turn off post splitting by defining a constant in your WordPress wp-config.php file.

define( 'ALGOLIA_SPLIT_POSTS', false );

You will need to re-index the indices to see the change.

Can I customize the Autocomplete dropdown look & feel?

Yes. You can find some detailed explanations on this page.

I have created a custom API key, but it is not accepted as a Search-Only API key in the plugin settings.

Creating a dedicated search API key is a good practice. If you want to be able to use that newly generated API key as the Search-Only API key, you have to make sure it only has the search ACL privilege. For security reasons, Algolia will reject every any Search-Only API key that has additional privileges.

In addition, Algolia also requires that the provided search API key has the TTL set to 0.

Will this plugin be compatible with my WordPress theme?

More than likely, “Yes”*.

For themes that implement standard WordPress search functionality, there should be no issues with either the Use Algolia in the backend or the Use Algolia with Instantsearch.js search page options.

Anyone on WP Search with Algolia version 2.3.x or lower, at time of this writing, should be compatible. The version of Autocomplete at this WPSwA version is still 0.38.x. Be aware that Autocomplete version 1.x changes how it finds and appends a search box and looks for <div id="autocomplete"></div> instead of <form><input type="text" name="s" /></form>

*Be aware that some themes and plugins modify WP_Query and/or implement their own custom search behavior that may not be compatible, and can potentially cause conflicts with the Use Algolia in the backend option for the search page. If that appears to affect you, try the Use Algolia with Instantsearch.js option to see if that resolves your issue.

My data is out of sync with Algolia

Sometimes your WordPress content gets out of sync with Algolia. For example, if you are changing your permalink templates, all of your URLs will change and Algolia will not know about it. Content can also get out of sync when you use filters to change settings or attributes to push to Algolia. Direct changes to the database that do not use standard WordPress methods for changing content can get out of sync. In any case you can simply re-index your content.

Can I use one Algolia account for multiple WordPress sites?

Definitely! In the same fashion that WordPress lets you prefix all database tables, Algolia allows you to prefix each index. This can be configured on the Algolia Search -> Settings page of the plugin.

Why doesn't my autocomplete dropdown show up?

  1. Check that the autocomplete feature is turned on on the Autocomplete page of the admin UI
  2. Check that you have selected at least one index to display and ensure those indices were created in Algolia

The indexing is slow, can I optimize the required time?

Yes, however it depends on your servers capacities and the number of plugins you have enabled. By default, the plugin only indexes 100 items per indexing process to ensure it doesn't reach PHP max execution time or memory limits.

Here is a way to increase the number of items indexed on each PHP indexing process:

<?php

function my_increase_indexing_batch_size() {
    return 200;
}
add_filter( 'algolia_indexing_batch_size', 'my_increase_indexing_batch_size' );

If indexing doesn't work after the change, it probably means you pushed the number too high.

Can I push my custom user attributes?

Yes. You can do so by using the algolia_user_record filter:

<?php

/**
 * @param array   $record
 * @param WP_User $user
 *
 * @return array
 */
function my_custom_user_record( array $record, WP_User $user ) {
    $record['custom_field'] = get_user_meta( $user->ID, 'custom_field', true );
    /* Add as many as you want. */

    return $record;
}

add_filter( 'algolia_user_record', 'my_custom_user_record', 10, 2 );

Can I use custom thumbnail sizes?

Yes. If the thumbnail size you are willing to display is medium, you can do:

<# if ( data.images.medium ) { #>
    <img class="suggestion-post-thumbnail" src="{{ data.images.medium.url }}" alt="{{ data.post_title }}">
<# } #>

The plugin does not push all thumbnail sizes by default to avoid huge record payloads. You now need to use a filter hook that allows you to specify the thumbnail sizes you want to push. i.e.

<?php

function my_extra_post_images_sizes( $sizes ) {
    $sizes[] = 'medium';

    return $sizes;
}
add_filter( 'algolia_post_images_sizes', 'my_extra_post_images_sizes' );

My issue is not listed here, what to do?

If your issue is not covered here, please submit an issue with the error details here: https://github.com/WebDevStudios/wp-search-with-algolia/issues

⚠️ **GitHub.com Fallback** ⚠️