Plugin ArchitectureDatabase Structure

Database Table Structure

WP Fast Total Search (WPFTS) uses several tables in the WordPress database to store the search index and other information necessary for plugin operation. The default table prefix is wpftsi_, but it can be changed depending on WordPress Multisite settings. If your WordPress Multisite network has a blog with an ID other than 1, the table prefix will be wpftsi_{blog_id}_. You can obtain the table prefix using the WPFTS_Core::dbprefix() method.

Here is a description of each table:

  • wpftsi_docs: Stores information about documents (posts, pages, etc.) that have been indexed.

    • id (int): Unique record identifier. Primary key, auto-increment.

    • index_id (int): ID of the record in the wpftsi_index table. Foreign key.

    • token (varchar(255)): Cluster name (e.g., post_title, post_content).

    • n (int unsigned): Number of words in the cluster for this document.

  • wpftsi_index: Stores the main information about indexed records.

    • id (int unsigned): Unique record identifier. Primary key, auto-increment.

    • tid (bigint unsigned): ID of the post or other object in WordPress.

    • tsrc (varchar(255)): Data source (e.g., wp_posts).

    • tdt (datetime): Date and time of the last post modification.

    • build_time (int): Post indexing timestamp. 0 - not indexed. 9999 - in progress. >10000 - indexed.

    • update_dt (datetime): Date and time of the last update of the record in the index.

    • force_rebuild (tinyint): Flag indicating the need for re-indexing (0 - no, 1 - yes, 2 - high priority).

    • locked_dt (datetime): Date and time of record locking (to prevent simultaneous indexing).

    • rules_idset (varchar(255)): Set of indexing rule IDs applied to this post.

  • wpftsi_stops: Stores a list of stop words that are ignored during indexing.

    • id (int unsigned): Unique record identifier. Primary key, auto-increment.

    • word (varchar(255)): Stop word.

  • wpftsi_vectors: Stores information about the frequency of words in documents.

    • wid (int): ID of the word in the wpftsi_words table. Part of the composite primary key.

    • did (int): ID of the document in the wpftsi_docs table. Part of the composite primary key.

    • wn (int): Position of the word in the document.

  • wpftsi_words: Stores a dictionary of all words found in the indexed documents.

    • id (int): Unique word identifier. Primary key, auto-increment.

    • word (varchar(255)): The word itself.

    • act (int): Number of documents in which this word occurs. -1 - data is outdated and the cache needs to be updated.

  • wpftsi_tw: Temporary table for storing words and their positions before adding to wpftsi_vectors.

    • id (int): Unique record identifier. Primary key, auto-increment.

    • w (varchar(255)): Word.

    • did (int): Document ID.

    • wn (int): Position of the word in the document.

  • wpftsi_vc: (Vector Cache) Stores cached word vectors to optimize search.

    • id (int): Unique record identifier. Primary key, auto-increment.

    • wid (int): Word ID.

    • upd_dt (datetime): Date and time of the last cache update.

    • vc (longblob): Binary vector data.

  • wpftsi_tp: (Temporary/permanent Relevance) Stores intermediate results of relevance calculation.

    • id (bigint unsigned): Unique record identifier. Primary key, auto-increment.

    • q_id (int): Search query ID in the wpftsi_qlog table.

    • did (int): Document ID.

    • pow (int): Document “power”.

    • res (float): Document relevance.

    • ts (timestamp): Record creation time.

  • wpftsi_qlog: Stores a log of search queries.

    • id (int): Unique query identifier. Primary key, auto-increment.

    • query (longtext): Search query.

    • query_type (varchar(255)): Query type (e.g., wpmainsearch_admin, wpmainsearch_frontend).

    • preset (varchar(255)): Preset used.

    • widget_name (varchar(255)): Widget name (if the query was performed through a widget).

    • n_results (int): Number of results found.

    • q_time (float): Query execution time.

    • max_ram (bigint): Maximum amount of memory used.

    • user_id (bigint): ID of the user who performed the query.

    • req_ip (varchar(40)): User’s IP address.

    • ref_url (text): URL of the page from which the query was performed.

    • insert_dt (datetime): Date and time of the query.

    • wpq_params (longtext): JSON-encoded WP_Query query parameters.

    • ext (longtext): Additional data (log).

  • wpftsi_map: Stores the correspondence between posts and other objects (e.g., files). Used to index data related to posts but stored in other tables.

    • id (bigint unsigned): Unique record identifier. Primary key, auto-increment.

    • post_id (bigint unsigned): Post ID in WordPress.

    • obj_id (bigint unsigned): External object ID.

    • obj_type (varchar(50)): External object type.

  • wpftsi_queue: Indexer task queue. Not used in the current version of the plugin.

    • id (bigint unsigned): Unique task identifier. Primary key, auto-increment.

    • post_id (bigint unsigned): Post ID.

    • remark (varchar(255)): Additional information about the task.

    • insert_dt (datetime): Date and time the task was added to the queue.

  • wpftsi_rawcache: Cache of raw data extracted from posts and other sources. Used to speed up indexing.

    • id (int unsigned): Unique record identifier. Primary key, auto-increment.

    • object_id (bigint): Object ID in WordPress.

    • object_type (varchar(150)): Object type (e.g., wp_post).

    • cached_dt (datetime): Date and time of the last object modification.

    • insert_dt (datetime): Date and time the data was added to the cache.

    • method_id (varchar(150)): Identifier of the method by which the data was obtained.

    • data (longtext): Serialized data.

    • error (text): Error information (if any).

    • filename (text): File name (for attachments).

  • wpftsi_ilog: (Indexer Log) Stores the indexer’s operation log.

    • id (int unsigned): Unique record identifier. Primary key, auto-increment.

    • index_id (int unsigned): ID of the record in the wpftsi_index table.

    • start_ts (double): Timestamp of the start of indexing.

    • getpost_ts (double): Time spent getting post data.

    • clusters_ts (double): Time spent processing clusters.

    • cluster_stats (longtext): Cluster statistics (data size).

    • reindex_ts (double): Total indexing time.

    • status (int): Indexing status.

    • error (longtext): Error information.

  • wpftsi_irules: Stores indexing rules.

    • id (int unsigned): Unique rule identifier. Primary key, auto-increment.

    • ident (varchar(130)): Unique rule identifier (slug).

    • filter_hash (varchar(50)): Filter condition hash.

    • act_hash (varchar(50)): Rule actions hash.

    • rule_snap (longtext): JSON-encoded rule data.

    • clone_id (int): ID of the parent rule (for cloned rules).

    • filter_sql (longtext): SQL code of the filter condition.

    • is_valid (int): Flag indicating whether the rule is correct.

    • error_msg (longtext): Error message (if any).

    • ord (int): Rule execution order.

    • type (int): Rule type (0 - basic, 1 - custom, 2 - final, 3 - temporary).

    • insert_dt (datetime): Date and time the rule was created.

  • wpftsi_doctree: Stores information about nested data. Used to index content that is indirectly related to the post, for example, through another post or object.

    • id (int unsigned): Unique record identifier. Primary key, auto-increment.

    • p_tid (bigint unsigned): Parent object ID.

    • p_tsrc (varchar(255)): Parent object source.

    • p_token (varchar(255)): Parent object cluster.

    • c_tid (bigint unsigned): Child object ID.

    • c_tsrc (varchar(255)): Child object source.

    • c_token (varchar(255)): Child object cluster.

More detailed information about each table and its fields is provided in the plugin’s API documentation. Addon developers need to understand the WPFTS table structure for correct integration with the plugin.