FAQ - Indexing

  1. How long does indexing take?
  2. What to do if indexing does not complete or hangs?
  3. How to reindex posts added by a script?
  4. Can I exclude specific files from indexing?
  5. How to index files uploaded outside the Media Library?
  6. Why are files uploaded via WP Download Manager not indexed?
  7. Can I index the content of files uploaded via RCWD Upload for ACF?
  8. How to index shortcode content?
  9. How to index post tags?

How long does indexing take in WPFTS?

The indexing time in WPFTS depends on several factors and can vary from a few minutes to several hours. Here are the main factors affecting indexing speed:

  • Content volume: The more posts, pages, files, and other elements on your site, the longer the indexing will take.
  • File size: Indexing large files (e.g., multi-page PDF documents) takes longer than indexing small text files.
  • Content type: Indexing different content types (text, images, video) can take different amounts of time.
  • Server performance: The speed of your hosting directly affects the indexing speed. Indexing will be faster on more powerful servers.
  • Plugin settings: Enabling additional indexing options, such as indexing metadata or file content, can increase indexing time.
  • Presence of third-party plugins: Some plugins can slow down WPFTS and increase indexing time.
  • Server load: If your server is already heavily loaded, indexing may take longer.

Optimizing indexing time:

You can optimize indexing time by following these tips:

  • Index only necessary content: Disable indexing of post types or files that don’t need to be searchable.
  • Optimize file size: Reduce the size of large files, especially PDF documents, before uploading them to the site.
  • Use powerful hosting: If your site contains a lot of content, we recommend using hosting with sufficient resources.
  • Perform indexing during periods of low server load: For example, at night or early morning.
  • Disable unnecessary plugins during indexing: This can help speed up the process.
  • Break indexing into stages: If you have a lot of content, you can index it in parts, selecting different post types or files for each stage.

Monitoring the indexing process:

You can monitor the indexing process in real-time on the WPFTS settings page. It displays indexing progress, remaining time, and other information.

If indexing takes too long or hangs, contact our support team. We will help you identify and resolve the cause of the problem.


What to do if indexing in WPFTS does not complete or hangs?

A hanging or incomplete index in WPFTS can be caused by various reasons. Here are some steps to help you diagnose and solve the problem:

1. Check error logs:

  • WPFTS logs: WPFTS keeps its own error log, which may contain useful information about the cause of the hang. The path to the log is usually indicated on the plugin settings page.
  • Web server logs: Check your web server’s error logs (Apache or Nginx). There may be entries about exceeding the script execution time limit, insufficient memory, or other errors that can lead to indexing hanging.
  • WordPress logs: Enable debug mode in WordPress by adding the following lines to the wp-config.php file:
define( 'WP_DEBUG', true );
define( 'WP_DEBUG_LOG', true );

This will log all WordPress errors to the wp-content/debug.log file.

2. Check server resources:

  • Memory limit: Make sure your PHP script has enough memory allocated. Increase the memory_limit value in the php.ini or .htaccess file. The recommended value is at least 256M.
  • Execution time limit: Increase the max_execution_time value in the php.ini or .htaccess file. This will allow the indexing script to run longer without timing out.
  • Server load: High server load can lead to indexing hanging. Try performing indexing during a period of low load, such as at night.

3. Check for conflicts with other plugins and the theme:

  • Temporarily disable other plugins: Sometimes other plugins can conflict with WPFTS and lead to indexing hanging. Try disabling plugins one by one to identify the source of the problem.
  • Switch to the default WordPress theme: If you are using a custom theme, try temporarily switching to the default theme (e.g., Twenty Twenty-Four). This will help rule out theme compatibility issues.

4. Check plugin settings:

  • Optimize indexing settings: Disable indexing of unnecessary content (e.g., metadata or comments) to reduce indexing time.
  • Divide indexing into stages: If you have a lot of content, try indexing it in parts, selecting different post types or files for each stage.

5. Contact support:

If you have performed all the steps above, but the problem is not resolved, contact WPFTS support. Describe your problem in detail, specify the plugin version, WordPress version, theme, and list of active plugins. Also, attach error logs, if any. We will help you find and fix the cause of the indexing hang.

Don’t panic if indexing hangs. In most cases, the problem can be solved by following these recommendations.


How to reindex posts added by a script in WPFTS?

If you add or modify posts on your WordPress site programmatically, using a script, WPFTS may not always automatically detect these changes and update the search index. In this case, you need to manually trigger reindexing for these posts.

Using the wpfts_post_reindex() function:

WPFTS provides a special function wpfts_post_reindex(), which allows you to reindex individual posts. Here’s how to use it:

  1. Get the post ID: After adding or modifying a post using a script, save its ID.

  2. Call the wpfts_post_reindex() function: In your script, after saving the post, call the wpfts_post_reindex() function, passing it the post ID as an argument:

wpfts_post_reindex( $post_id );

Where $post_id is the ID of the post to be reindexed.

Example:

// ... your code for adding or modifying the post ...
 
$post_id = wp_insert_post( $post_data ); // Or another way to save the post
 
if ( ! is_wp_error( $post_id ) ) {
  // Post successfully saved, reindex it
  wpfts_post_reindex( $post_id );
}

Alternative method (less efficient):

You can use the wpfts_index_rebuild() function to completely rebuild the search index. However, this method is less efficient than using wpfts_post_reindex(), especially if you have many posts on your site. A complete index rebuild takes significantly longer.

Important notes:

  • The wpfts_post_reindex() function is only available in the Pro version of WPFTS.
  • Make sure the WPFTS plugin is activated before calling the wpfts_post_reindex() function.
  • If you use caching on your site, remember to clear the cache after reindexing posts.

Using the wpfts_post_reindex() function, you can ensure the accuracy of the WPFTS search index when programmatically adding or modifying posts. This will allow your visitors to find all the content on your site, including posts added by a script.


Can I exclude specific files from indexing in WPFTS?

Yes, WPFTS provides several ways to exclude specific files from indexing. This can be useful if you have files that should not be searchable, such as confidential documents or temporary files.

Ways to exclude files from indexing:

  1. Exclusion by file type: In the WPFTS Pro settings, you can specify which file types should be indexed. Simply uncheck the boxes of the file types you want to exclude. This is the easiest way to exclude entire groups of files.

  2. Exclusion by attachment ID: If you need to exclude specific files, you can use their IDs. Add the following code to your theme’s functions.php file (or a child theme):

add_filter('wpfts_index_pre_filter', function($where, $args) {
  // List of file IDs to exclude
  $excluded_attachment_ids = array(123, 456, 789);
 
  if (!empty($excluded_attachment_ids)) {
    $where .= " AND {$args['table']}.tid NOT IN (" . implode(',', $excluded_attachment_ids) . ")";
  }
 
  return $where;
}, 10, 2);

Replace 123, 456, 789 with the IDs of the files you want to exclude. This code will add a NOT IN condition to the SQL query used to select files for indexing.

  1. Exclusion by file URL: You can also exclude files by their URL. Add the following code to your theme’s functions.php file (or a child theme):
add_filter('wpfts_should_index_attachment', function($should_index, $attachment_id) {
    $excluded_urls = array(
        'https://example.com/wp-content/uploads/private-document.pdf',
        'https://example.com/wp-content/uploads/another-private-file.docx',
    );
    $attachment_url = wp_get_attachment_url($attachment_id);
 
    if (in_array($attachment_url, $excluded_urls)) {
        return false;
    }
 
  return $should_index;
}, 10, 2);

Replace the URLs in the $excluded_urls array with the URLs of the files you want to exclude.

  1. Exclusion by parent post: If files are attached to specific posts or pages that you want to exclude from the search, you can exclude these parent posts, and the attached files will also be excluded. This can be done in the WPFTS settings, excluding specific post types, or using similar code as for exclusion by attachment ID, but applying it to post_parent.

After excluding files:

After you have excluded files from indexing, you need to rebuild the search index for the changes to take effect. This can be done on the WPFTS settings page.

By choosing the appropriate method, you can flexibly manage file indexing and exclude unnecessary or confidential information from the search.


How to index files uploaded outside the Media Library?

WPFTS by default indexes files uploaded through the standard WordPress Media Library. However, many plugins and themes upload files directly to server folders, bypassing the Media Library. In this case, WPFTS will not be able to automatically detect and index these files.

How to index files uploaded by third-party plugins:

To index files uploaded outside the Media Library, you will need some code modification using the wpfts_index_post hook. Here is a general algorithm of actions:

  1. Determine how the plugin stores file information: You need to find out how the plugin stores the paths to the files. This information is usually stored in the database as post metafields or in a separate table. Review the plugin’s documentation or explore the database to find this information.

  2. Use the wpfts_index_post hook: This hook allows you to add custom content to the WPFTS index. Inside the hook handler function, you need to get the file path and extract its content.

  3. Extract the file content: Use the WPFTS_Utils::GetCachedFileContent_ByLocalLink() function to extract the file content. This function takes the file path as an argument and returns an array with file data, including the content.

  4. Add the file content to the index: Add the extracted content to the WPFTS index using a key, such as external_file_content.

Example code:

Let’s assume the plugin stores the file path in the _external_file_path metafield. Then the code for indexing would look like this:

add_filter('wpfts_index_post', function($index, $post) {
    global $wpfts_core;
 
    if (metadata_exists('post', $post->ID, '_external_file_path')) {
        $file_path = get_post_meta($post->ID, '_external_file_path', true);
 
        require_once $wpfts_core->root_dir.'/includes/wpfts_utils.class.php';
        $file_content = WPFTS_Utils::GetCachedFileContent_ByLocalLink($file_path, false, true);
 
 
        if (isset($file_content['post_content'])) {
            $index['external_file_content'] = $file_content['post_content'];
        }
    }
 
    return $index;
}, 10, 2);

Index rebuilding:

After adding the code, remember to rebuild the WPFTS search index so that the new files are included in the index.

Important points:

  • File path: Make sure the file path is correct and readable by the WordPress script.
  • Supported file types: WPFTS supports indexing only certain file types (PDF, DOCX, TXT, etc.). Check the plugin documentation for compatibility with your file type.
  • Performance: Indexing a large number of files can take a lot of time and server resources. Optimize files before uploading and perform indexing during periods of low load.

This method allows you to integrate WPFTS with almost any plugin or theme that uploads files outside the Media Library. If you have any difficulties with the setup, contact WPFTS support.


Why are files uploaded via WP Download Manager not indexed?

WP Download Manager (WPDM) is a popular download management plugin that stores files separately from the WordPress Media Library. By default, WPFTS does not index files managed by WPDM, so they will not appear in search results.

Solution:

To index WPDM files, you need to install and activate the free add-on “WPFTS Add-on for WP Download Manager”. This add-on integrates WPFTS with WPDM, allowing you to index uploaded files and display them in search results.

Installation and configuration:

  1. Install and activate the add-on: You can find the add-on in the official WordPress plugin repository by searching for “WPFTS Add-on for WP Download Manager”. After installation, remember to activate the add-on.

  2. Check WPFTS settings: Make sure that attachment (file) indexing is enabled in the WPFTS settings. This can be done on the “Indexing Settings” tab in the “Post Types” section.

  3. Rebuild the search index: After installing and activating the add-on, rebuild the WPFTS search index. This can be done on the “Tools” tab.

  4. (Optional) Configure result display: You can customize how WPDM search results are displayed on the search results page. For example, you can enable the display of file thumbnails or change the output format of file information.

Potential problems and their solutions:

  • Files are still not indexed after installing the add-on: Make sure you are using compatible versions of WPFTS, the add-on, and WPDM. Compatibility information is usually listed on the add-on page in the plugin repository. Also, try clearing your site and browser cache.

  • Indexing takes too long: If you have a large number of files, indexing can take a significant amount of time. Make sure your server has enough resources (memory and script execution time).

  • Problems with result display: If the search results are displayed incorrectly, check the display settings in WPFTS and the settings of your WordPress theme.

If WPDM files are still not indexed after performing all these steps, contact WPFTS support. Provide information about the versions of the plugins and theme, as well as a description of the problem. We will try to help you configure the indexing of WPDM files.


Can I index the content of files uploaded via RCWD Upload for ACF?

RCWD Upload for Advanced Custom Fields (ACF) is a convenient tool for uploading files and attaching them to posts via custom fields. However, WPFTS by default does not index files uploaded through RCWD Upload, as they are not stored in the standard WordPress Media Library.

Solution:

To index the content of files uploaded via RCWD Upload, you will need a special add-on “WPFTS Add-on for RCWD Uploader”. This add-on integrates WPFTS with RCWD Upload, allowing you to extract the content of uploaded files and add it to the search index.

Installation and configuration:

  1. Install and activate the add-on: You can download the addon from our website. Install it like a regular WordPress plugin and activate it.

  2. Check WPFTS settings: Make sure that indexing of ACF custom fields, where files uploaded via RCWD Upload are stored, is enabled in the WPFTS settings. This can be done on the “Indexing Settings” tab in the “Custom Fields” section.

  3. Rebuild the search index: After installing and activating the add-on, rebuild the WPFTS search index so that the new files are included in the index. This can be done on the “Tools” tab.

How the add-on works:

The add-on uses the wpfts_index_post hook to access post data during indexing. It extracts the path to the file uploaded via RCWD Upload from the corresponding ACF custom field. Then the add-on uses WPFTS functions to extract the file content and add it to the search index.

Important notes:

  • Compatibility: Make sure the versions of WPFTS, ACF, and RCWD Upload are compatible with each other. Check the add-on documentation for compatibility information.

  • Performance: Indexing file content may require significant server resources, especially with a large number of files.

If you have problems installing or configuring the add-on, contact WPFTS support.

Without this add-on, WPFTS will not be able to index the content of files uploaded via RCWD Upload. Installing the add-on is a necessary step to ensure full search functionality across all files on your site.


How to index shortcode content in WPFTS?

Shortcodes are a convenient way to insert dynamic content into WordPress posts and pages. However, standard WordPress search and WPFTS by default only index the shortcode text itself, not the content it generates. This means that the content output by the shortcode will not be considered during the search.

Solution:

WPFTS provides the ability to index content generated by shortcodes. To do this, you need to enable the corresponding option in the plugin settings.

Enabling shortcode indexing:

  1. Open the WPFTS settings page in the WordPress admin panel.

  2. Go to the “Indexing Engine” tab.

  3. In the “Indexing Defaults” section, find the option “Index shortcodes content” and check the box.

  4. Save the changes.

Rebuilding the index:

After enabling this option, you must rebuild the search index so that WPFTS indexes the content generated by shortcodes. This can be done on the “Tools” tab by clicking the “Rebuild Index” button.

How it works:

With the “Index shortcodes content” option enabled, WPFTS executes all shortcodes contained in the post text before indexing. Thus, not the shortcode text itself, but the actual content that it outputs, is included in the index. This allows you to find posts by the content generated by shortcodes.

Important notes:

  • Performance: Processing shortcodes can slow down indexing, especially if you have many posts with complex shortcodes.

  • Conflicts: In rare cases, shortcode indexing can lead to conflicts with other plugins. If you notice problems after enabling this option, try temporarily disabling other plugins to identify the source of the conflict.

  • Not all shortcodes can be indexed: Some shortcodes may generate content that cannot be indexed, such as interactive elements or videos.

Enabling shortcode indexing is an important step to ensure full search functionality on your site. This will allow your visitors to find posts not only by their text content, but also by the content generated by shortcodes.


How to index post tags in WPFTS?

By default, WPFTS indexes post titles and content, but not post tags. If you want users to be able to find posts by tags, you need to add tags to the search index.

Adding tags to the index:

The easiest way to add tags to the index is to use the wpfts_index_post hook. This hook allows you to add arbitrary content to the WPFTS index for each post.

Here’s an example code that adds tags to the index:

add_filter('wpfts_index_post', function($index, $post) {
  if ($post->post_type === 'post') { //  Check if it's a post
 
    $tags = get_the_terms($post->ID, 'post_tag');
    if ( $tags && ! is_wp_error( $tags ) ) {
        $tag_names = array();
        foreach ( $tags as $tag ) {
            $tag_names[] = $tag->name;
        }
        $index['post_tags'] = implode(' ', $tag_names); // Add tags to the index
    }
 
  }
  return $index;
}, 10, 2);

Code explanation:

  1. add_filter('wpfts_index_post', ...): This code registers a function that will be called when each post is indexed.

  2. if ($post->post_type === 'post'): We check that the current post is a post of type “post”. If you have other post types for which you need to index tags, add them to the condition.

  3. $tags = get_the_terms($post->ID, 'post_tag');: This function gets all tags attached to the current post.

  4. if ( $tags && ! is_wp_error( $tags ) ): We check that tags exist and no errors occurred when retrieving them.

  5. foreach loop: We iterate through all tags and add their names to the $tag_names array.

  6. $index['post_tags'] = implode(' ', $tag_names);: We combine all tag names into a single string, separated by spaces, and add it to the WPFTS index with the key post_tags. This will create a separate cluster in the index for tags.

  7. return $index;: Return the modified $index array.

Rebuilding the index:

After adding the code to functions.php, remember to rebuild the search index so that WPFTS indexes the tags for all your posts. This can be done on the WPFTS settings page under the “Tools” tab by clicking the “Rebuild Index” button.

Now, when you search for a word that is a tag of some post, that post will be displayed in the search results. You can also use the post_tags key to adjust the relevance weight of tags in the WPFTS settings.