Note: You are viewing the documentation for Version 4View Version 3 Docs

Hooks

SearchWP includes a number of hooks to allow unique customization without compromising the plugin code itself. Integrating with SearchWP using hooks will allow your modifications to remain in place even when upgrading SearchWP over time.

If you have not used hooks before please follow this SearchWP customizations plugin creation guide.

Query

searchwp\query
Using this hook you can directly manipulate the search query itself.
searchwp\query\args
Customize the arguments for a \SearchWP\Query which is used to perform all search queries.
searchwp\query\do_source_db_where
Control whether SearchWP considers the db_where() criteria for Sources. This functionality adds a layer of protection against content edits that were made in such a way that SearchWP’s indexer was not able to capture. If you are confident that your content edits are all taking place through APIs as captured by the Sources you’re using […]
searchwp\query\logic\{$type}\strict
Influence how SearchWP works through its various logic passes when performing searches. By default SearchWP will iterate through a series of logic passes when performing searches in this order: phrase (i.e. “quoted”, sentence searches) and (i.e. all search terms present in all results) or (i.e. any search terms present in any result) After each pass, […]
searchwp\query\logic\and
Control whether AND logic is performed.
searchwp\query\logic\phrase
Control whether SearchWP supports quoted phrases.
searchwp\query\mods
Customize the \SearchWP\Mods applied during a search. Note: There are some internal \SearchWP\Mods that may be present for the query. This hook does not allow filtration of those mission critical \SearchWP\Mods, only user-defined \SearchWP\Mods. See also searchwp\query\do_source_db_where for internals.
searchwp\query\output_suggested_search
Control whether SearchWP automatically suggests search fixes.
searchwp\query\partial_matches
Control whether SearchWP applies its partial matching logic when necessary.
searchwp\query\partial_matches\buoy
Control whether exact matches are given extra relevance weight when performing partial match logic.
searchwp\query\partial_matches\did_you_mean
Control whether SearchWP’s performs “Did you mean?” style corrections to searches that apply partial matching logic.
searchwp\query\partial_matches\force
Force SearchWP to execute its partial matching logic despite results being found.
searchwp\query\partial_matches\fuzzy
Control whether partial matching logic uses fuzzy matching. By default (when enabled) SearchWP will utilize two levels of partial matching logic. Find partial matches that contain the search string If no partial matches are found attempt to find tokens that sound like search terms
searchwp\query\partial_matches\fuzzy\force
By default (when partial matching is enabled) SearchWP will apply two levels of partial matching logic. The first will be the application of direct partial matches, and if no partial matches are found another level of fuzzy logic will be applied. This hook can force that fuzzy logic to be applied even if partial matches […]
searchwp\query\partial_matches\fuzzy\minimum_length
Control the minimum length for fuzzy matches.
searchwp\query\partial_matches\fuzzy\threshold
Control the threshold that determines whether a potential fuzzy partial match is considered a match.
searchwp\query\partial_matches\minimum_length
Control the minimum length for partial matches.
searchwp\query\partial_matches\tokens
Manipulate partial match tokens during partial match logic application.
searchwp\query\partial_matches\wildcard_after
Control whether a wildcard is added after a search query when performing partial match logic.
searchwp\query\partial_matches\wildcard_before
Control whether a wildcard is added before a search query when performing partial match logic.
searchwp\query\per_page
Customize how many results are returned per page.
searchwp\query\result\load_data
Control whether SearchWP loads applicable Entry Attribute data for search results. Note: When this functionality is enabled, only the Attribute data added to the Engine will be loaded. See also searchwp\query\result\load_data\all_attributes
searchwp\query\result\load_data\all_attributes
Control whether SearchWP loads all Entry Attribute data for search results. Note: When this functionality is enabled, all registered Attribute data will be loaded. See also searchwp\query\result\load_data
searchwp\query\results
Modify the results found by SearchWP.
searchwp\query\search_string
Customize the search string for a Query.
searchwp\query\tokens\limit
Control the maximum number of accepted search tokens.
searchwp\query\tokens\use_stems
Control whether token keyword stems are used for a Query.

Post

searchwp\source\post\{$post_type}\attribution
Control whether results from a post type can be configured to attribute all weight to another post ID.
searchwp\source\post\{$post_type}\parent_attribution
Control whether results from a post type can be configured to attribute relevance weight to their parents.
searchwp\source\post\{$post_type}\parent_attribution\strict
Control how Posts without a parent are returned when parent attribution has been enabled.
searchwp\source\post\attributes\comment
Customize a Comment before it is indexed.
searchwp\source\post\attributes\comments\args
Control the arguments used to retrieve Comments for a post during indexing.
searchwp\source\post\attributes\comments\author
When Comments have been added to a WP_Post-based Source, control whether the Comment Author is indexed.
searchwp\source\post\attributes\comments\email
When Comments have been added to a WP_Post-based Source, control whether the Comment Email is indexed.
searchwp\source\post\attributes\content
Customize post content prior to it being indexed.
searchwp\source\post\attributes\content\do_blocks
Control whether SearchWP processes block editor (Gutenberg) blocks prior to indexing.
searchwp\source\post\attributes\meta
Manipulate Custom Field (postmeta) data before it is indexed. See also searchwp\source\post\attributes\meta\${meta_key} for a single Custom Field.
searchwp\source\post\attributes\meta\{$meta_key}
Manipulate Custom Field (postmeta) data for a single Custom Field before it is indexed. See also searchwp\source\post\attributes\meta\${meta_key} for all Custom Fields.
searchwp\source\post\attributes\meta\ignored
By default SearchWP ignores meta keys that do not contain search-worthy content. You can customize which key(s) are ignored with this hook.
searchwp\source\post\attributes\taxonomy\term
Manipulate the taxonomy terms for a post prior to indexing. Applies only when the Taxonomy has been included in an Engine. See also searchwp\source\post\attributes\taxonomy\terms to filter all terms at once.
searchwp\source\post\attributes\taxonomy\terms
Manipulate the taxonomy terms for a post prior to indexing. Applies only when the Taxonomy has been included in an Engine. See also searchwp\source\post\attributes\taxonomy\term to filter individual terms.
searchwp\source\post\global_excerpt
Control whether SearchWP finds a ‘global’ excerpt from all post content, not just post_content.
searchwp\source\post\global_excerpt\{$post_type}
Control whether SearchWP finds a ‘global’ excerpt from all post content, not just post_content for a single post type.

Tokens

searchwp\tokens
Manipulate tokens both when indexing and searching.
searchwp\tokens\apply_rules_to_pattern_matches
Control whether SearchWP applies its validation rules (e.g. minimum length) to regular expression (regex) pattern matches.
searchwp\tokens\minimum_length
Control what SearchWP uses as a minimum token (search term) length.
searchwp\tokens\regex_patterns
SearchWP searches for regular expression pattern matches to keep certain strings in tact and avoid tokenization which may reduce the usefulness during search. By default there are a number of common regular expression patterns to extract strings of SKUs, dates, initials, function names, version numbers, and more. You can use this hook to add your […]
searchwp\tokens\regex_patterns\only_full_matches
By default SearchWP will process only full matches for its regular expression patterns. If you would like SearchWP to also consider partial matches you may enable that behavior with this hook.
searchwp\tokens\strict
Control whether SearchWP is strict with tokens. When disabled (which is the default behavior) SearchWP will remove accents from characters.
searchwp\tokens\tokenize_pattern_matches
Control whether regex pattern matches are tokenized into individual parts.

Statistics

searchwp\admin\dashboard_widgets\statistics
As part of SearchWP’s Statistics feature a Dashboard Widget is provided to allow for quick oversight into your search statistics when you log in to your WordPress Admin.
searchwp\admin\dashboard_widgets\statistics\days
By default the Statistics Dashboard Widget shows popular searches over the past 30 days. Use this hook to modify that default.
searchwp\statistics\capability
Control the Capability necessary to view SearchWP’s Statistics.
searchwp\statistics\log
Control whether SearchWP logs this search.

Index

searchwp\index\aggressive_delta
By default SearchWP utilizes its background process when handling delta updates. This helps keep page load times to a minimum. If instead you would prefer that SearchWP applies delta updates inline with content edits you may use this hook.
searchwp\index\process\enabled
Control whether the Index delta handling process is enabled.
searchwp\index\rebuild
This action is fired any time the Index is reset, just prior to the rebuilding job is triggered.
searchwp\index\tokens_max
By default SearchWP will generate tokens in batches of 500 maximum. If you feel your server is capable of doing more than that, increasing this limit may improve performance of the indexing process. This hook can also be used to reduce the number of tokens generated per patch in case you are having trouble with […]

Stopwords

searchwp\stopwords
SearchWP uses Stopwords to both optimize the index and increase relevancy of search results. The primary method of customizing the list of Stopwords is by way of the Settings tab of the SearchWP Settings screen. You can however programmatically filter Stopwords as well.
searchwp\stopwords\suggestions
Control whether SearchWP suggests Stopwords.
searchwp\stopwords\suggestions\limit
Control the number of Stopwords suggestions shown by SearchWP.
searchwp\stopwords\suggestions\threshold
Control the threshold used to determine suggested Stopwords.

Document

searchwp\document\content
Customize extracted document content.
searchwp\document\pdf_metadata\skip
Whether PDF metadata should be skipped during indexing.
searchwp\document\skip
Control whether SearchWP should skip processing a document.

Parser

searchwp\parser\pdf
Utilize an external PDF parser to extract PDF content instead of SearchWP’s.
searchwp\parser\richtext
Utilize an external rich text parser to extract rich text content instead of SearchWP’s.
searchwp\parser\text
Utilize an external text parser to extract text content instead of SearchWP’s.

Indexer

searchwp\indexer\alternate
Control whether SearchWP uses its alternate indexer. SearchWP automatically detects when the alternate indexer is necessary but this hook overrides that detection. See also: Alternate Indexer
searchwp\indexer\batch_size
Control how many entries are indexed during each indexer batch.
searchwp\indexer\http_basic_auth_credentials
Teach the Indexer HTTP Basic Authentication credentials. Note: these credentials are for HTTP Basic Authentication, not your WordPress login credentials.

Debug

searchwp\debug
Control whether debugging is enabled.
searchwp\debug\dir
Modify where debug logs are stored.

Source

searchwp\source\attribute\options
Modify the Attribute Options for a Source.
searchwp\source\check_db
Control whether SearchWP validates a Source’s database properties.

Entry

searchwp\entry\data
Customize an \SearchWP\Entry before it is indexed.
searchwp\entry\native
Customize the native object of a \SearchWP\Entry.

Highlighter

searchwp\highlighter\case_insensitive
Control case sensitivity when highlighting.
searchwp\highlighter\partial_matches
Control whether highlighting considers partial matches.

Attribute

searchwp\source\attribute\label
Customize Source Attribute Label

License

searchwp\license\key
Programmatically define your license key.

Native

searchwp\native\short_circuit
Control whether SearchWP overrides native WordPress searches.

Settings

searchwp\settings\capability
Control the Capability necessary to edit SearchWP’s settings.

SWP_Query

searchwp\swp_query\args
Modify the arguments used when instantiating SWP_Query.

AdminBar

searchwp\admin_bar
Control whether SearchWP’s Admin Bar entry is enabled.

Synonyms

searchwp\synonyms
SearchWP uses Synonyms to both optimize the index and increase relevancy of search results. The primary method of customizing the list of Synonyms is by way of the Settings tab of the SearchWP Settings screen. You can however programmatically filter Synonyms as well.

Misc

searchwp\extensions
Register an Extension to be used in SearchWP, specifically in the Extensions menu of the SearchWP settings UI.
searchwp\missing_integration_notices
By default SearchWP will check to see if there are any missing integration Extensions. You can disable that behavior with this hook.
searchwp\nuke_on_delete
Whether SearchWP deletes all data on uninstallation
searchwp\options\dashboard_stats_link
Control whether SearchWP’s Statistics link appears.
searchwp\options\settings_screen
Control whether SearchWP’s options page appears.
searchwp\post__in
Control a global limiter for \WP_Post IDs that are considered during indexing and searching.
searchwp\post__not_in
Control a global exclusion of \WP_Post IDs to consider during indexing and searching.
searchwp\post_stati
Control the considered post stati for \WP_Post-based Sources.
searchwp\sources
Control what content can be indexed and searched by SearchWP.
searchwp\valid_html_tags
Control which HTML tags SearchWP will consider when extracting content to index.
searchwp\weights
Customize the weight intervals available when configuring SearchWP Engine Source Attributes.
Fix keyword search on your site. No coding required!

Now you can utilize all of the content that's gone unrecognized by native WordPress keyword search instantly with SearchWP

Get SearchWP