前言介紹
- 這款 WordPress 外掛「Solr Search for WordPress」是 2015-11-19 上架。
- 目前有 100 個安裝啟用數。
- 上一次更新是 2024-12-09,距離現在已有 145 天。
- 外掛最低要求 WordPress 4.6 以上版本才可以安裝。
- 外掛要求網站主機運作至少需要 PHP 版本 7.1 以上。
- 有 2 人給過評分。
- 還沒有人在論壇上發問,可能目前使用數不多,還沒有什麼大問題。
外掛協作開發者
10up | pwtyler | mattleff | jspellman | getpantheon | jazzs3quence | mikengarrett | andrewtaylor-1 | collinsinternet | danielbachhuber | outlandish-josh |
外掛標籤
search |
內容簡介
搜索對於您的網站至關重要,但是 WordPress 的默認搜索功能仍有很多缺點。使用 Apache Solr 搜索引擎,改善您的 WordPress 網站的用戶體驗。
更快的搜尋結果和更高的準確率。
可以在標籤、分類、作者和頁面類型等方面進行篩選。
自定義字段的索引和篩選。
能夠使用 WP_Query 並設置 solr_integrate 參數以進行無縫銜接。
完全取代默認的 WordPress 搜尋,只需安裝和配置。
完全集成到默認的 WordPress 主題和搜尋小工具中。
非常適合開發人員,使用現代的 Solarium 库。
開發
這個外掛正在 GitHub 上積極開發:
https://github.com/pantheon-systems/solr-power
請隨時提交問題。我們也歡迎貢獻者!有關貢獻的詳細信息,請參閱 CONTRIBUTING.md。
有關其他文檔,例如可用篩選器和直接使用 SolrPower_Api 類的工作方式,請參閱項目 Wiki:
https://github.com/pantheon-systems/solr-power/wiki
您可能會注意到有兩個不同的測試運行在兩個不同的服務上:
Travis CI 在 Solr 實例上運行 PHPUnit 測試套件。
Circle CI 在 Pantheon 站點上運行 Behat 測試套件,以確保該插件與 Pantheon 平台相容。
這兩個測試套件都可以在本地運行,需要進行不同程度的設置。
PHPUnit 需要 WordPress PHPUnit 測試套件,以及可以命名為 wordpress_test 的數據庫的訪問權限。如果您尚未在本地配置測試套件,請運行 bash bin/install-wp-tests.sh wordpress_test root '' localhost。此外,您還需要訪問正在運行的 Solr 實例,以便對其執行測試套件。
Behat 需要啟用 Solr 的 Pantheon 站點。完成站點創建後,您需要安裝 Terminus,並設置 TERMINUS_TOKEN、TERMINUS_SITE 和 TERMINUS_ENV 環境變量。然後,您可以運行 ./bin/behat-prepare.sh 來為測試套件準備站點。
請注意,依賴關係是通過 Composer 安裝的,而 vendor 目錄未被提交到存儲庫中。您需要在本地運行 composer install,以使該外掛更為穩定。您可以在此處了解有關 Composer 的更多信息:https://getcomposer.org
WP-CLI 支持
這個外掛具有 WP-CLI 支持。
所有與 Solr Power 相關的命令都被分組到 wp solr 命令中,這是一個示例:
$ wp solr
usage: wp solr check-server-settings
原文外掛簡介
Search is critical for your site, but the default search for WordPress leaves a lot to be desired. Improve your user experience with the Apache Solr search engine for your WordPress website.
Fast results, with better accuracy.
Enables faceting on fields such as tags, categories, author, and page type.
Indexing and faceting on custom fields.
Drop-in support for WP_Query with the solr_integrate parameter set to true.
Completely replaces default WordPress search, just install and configure.
Completely integrated into default WordPress theme and search widget.
Very developer-friendly: uses the modern Solarium library
Development
This plugin is under active development on GitHub:
https://github.com/pantheon-systems/solr-power
Please feel free to file issues there. Pull requests are also welcome! See CONTRIBUTING.md for information on contributing.
For further documentation, such as available filters and working with the SolrPower_Api class directly, please see the project wiki:
https://github.com/pantheon-systems/solr-power/wiki
You may notice there are two sets of tests running, on two different services:
PHPUnit test suite against a Solr instance.
The Behat test suite against a Pantheon site, to ensure the plugin’s compatibility with the Pantheon platform.
Both of these test suites can be run locally, with a varying amount of setup.
PHPUnit requires the WordPress PHPUnit test suite, and access to a database with name wordpress_test. If you haven’t already configured the test suite locally, you can run bash bin/install-wp-tests.sh wordpress_test root '' localhost. You’ll also need access to a running Solr instance, in order to run the unit tests against Solr.
Behat requires a Pantheon site with Solr enabled. Once you’ve created the site, you’ll need install Terminus, and set the TERMINUS_TOKEN, TERMINUS_SITE, and TERMINUS_ENV environment variables. Then, you can run ./bin/behat-prepare.sh to prepare the site for the test suite.
Note that dependencies are installed via Composer and the vendor directory is not committed to the repository. You will need to run composer install locally for the plugin to function. You can read more about Composer here
WP-CLI Support
This plugin has WP-CLI support.
All Solr Power related commands are grouped into the wp solr command, see an example:
$ wp solr
usage: wp solr check-server-settings
or: wp solr delete [
or: wp solr index [--batch=
or: wp solr info [--field=
or: wp solr optimize-index
or: wp solr repost-schema
or: wp solr stats [--field=
See 'wp help solr
You can see more details about the commands using wp help solr:
**NAME**
wp solr
**DESCRIPTION**
Perform a variety of actions against your Solr instance.
**SYNOPSIS**
wp solr
**SUBCOMMANDS**
check-server-settings Check server settings.
delete Remove one or more posts from the index.
index Index all posts for a site.
info Report information about Solr Power configuration.
optimize-index Optimize the Solr index.
repost-schema Repost schema.xml to Solr.
stats Report stats about indexed content.
WP_Query Integration
Use Solr in a custom WP_Query instead of querying a database. Add 'solr_integrate' => true to the query arguments.
NOTE: Currently, only basic queries, tax_query, meta_query and date_query are supported. See examples/example.custom_WP_Query.php for an example.
A meta_query can use the following compare operators:
'='
'!='
'>'
'>='
'
Boosting relevancy score by publish date
The following guidance can be used to extend the Solr index and modify boosts beyond just this example.
To support math functions on dates, you must add a custom schema.xml to Solr and reindex with the new schema.
Add the following to schema.xml:
Add the following to your functions.php file.
post_date );
// Matches format required for TrieDateField
$doc->setField( 'post_date_iso', gmdate( 'c\Z', $post_time ) );
return $doc;
}
add_filter( 'solr_build_document', 'my_solr_build_document', 10, 2 );
/**
* Hooks into query processor, Dismax, to add publish date boost.
* See: https://www.metaltoad.com/blog/date-boosting-solr-drupal-search-results
*/
function my_solr_dismax_query( $dismax ) {
$dismax->setQueryParser( 'edismax' );
$dismax->setBoostQuery( 'recip(abs(ms(NOW/HOUR,post_date_iso),3.16e-11,1,1))' );
return $dismax;
}
add_filter( 'solr_dismax_query', 'my_solr_dismax_query' );
is_solr_query Filter
The is_solr_query filter controls whether Solr should be used for a specific query.
Parameters:
$enabled (bool): Indicates whether Solr should be used for the query. Defaults to true if the query is a search or if solr_integrate is set in the query.
$query (WP_Query): The current WordPress query object.
Return:
bool: true to enable Solr for the query, false to disable it.
add_filter( ‘is_solr_query’, function( $enabled, $query ) {
if ( $query->is_category( ‘news’ ) ) {
return false;
}
return $enabled;
}, 10, 2 );
Custom schema file path
By default, custom schema is sourced from wp-content/uploads/solr-for-wordpress-on-pantheon/schema.xml. This can be overridden with an absolute path using the the solr_power_customer_schema_file_path filter.
Parameters:
* $custom_schema_file_path (string): Default path to a custom schema file
Return:
* string: Absolute path to a custom schema.xml file.
add_filter('solr_power_customer_schema_file_path', function($custom_schema_file_path) {
return '/absolute/path/to/schema.xml';
});
Common issues
Failing to post the schema.xml will result in an error during indexing, “Missing post_date_iso field.”
If you have the field and type in the schema, but don’t add the solr_build_document filter, you will get a similar error.
If the post_date_iso field is missing from the index, Solr will ignore this boost and return regular results.
Trying to use a regular date field for the boost query will result in an error in the request instead of results.
Explicit Commit vs Autocommit
Once solr has sent the data to the solr server, solr must COMMIT the data to the index and adjust the index and relevancy ratings accordingly before that data can appear in search results.
By default, Solr Search for WordPress has auto-commit disabled. The index is committed when the uncommitted item is two minutes old, or the cron runs. By default, the cron runs on the Pantheon platform every hour.
When autocommit is enabled, Solr Search for WordPress commits data when it sends every post. When running on Pantheon, we recommend leaving autocommit disabled to aid overall site performance.
To enable autocommit, add the following to wp-config.php or an mu-plugin.
define( 'SOLRPOWER_DISABLE_AUTOCOMMIT', false );
To force-commit data outside of a normal cron run, from the command line, you can run the command below or simply force a cron-run.
wp solr commit
各版本下載點
- 方法一:點下方版本號的連結下載 ZIP 檔案後,登入網站後台左側選單「外掛」的「安裝外掛」,然後選擇上方的「上傳外掛」,把下載回去的 ZIP 外掛打包檔案上傳上去安裝與啟用。
- 方法二:透過「安裝外掛」的畫面右方搜尋功能,搜尋外掛名稱「Solr Search for WordPress」來進行安裝。
(建議使用方法二,確保安裝的版本符合當前運作的 WordPress 環境。
0.3 | 0.4 | 0.4.1 | 0.5.0 | 0.6.0 | 1.0.0 | 1.1.0 | 1.2.0 | 1.3.0 | 1.4.0 | 1.4.1 | 1.5.0 | 2.0.0 | 2.1.1 | 2.1.2 | 2.1.3 | 2.1.4 | 2.2.0 | 2.2.1 | 2.2.2 | 2.2.3 | 2.2.4 | 2.2.5 | 2.2.6 | 2.3.0 | 2.3.1 | 2.3.2 | 2.3.3 | 2.4.0 | 2.4.1 | 2.4.2 | 2.4.3 | 2.4.4 | 2.4.5 | 2.5.0 | 2.5.1 | 2.5.2 | 2.5.3 | 2.6.0 | trunk |
延伸相關外掛(你可能也想知道)
Search Regex 》Search Regex 提供了強大的搜尋和替換函數,可用於 WordPress 文章、頁面、自定義文章類型等數據源的搜尋與替換,這些功能超越了標準搜尋功能,讓你可以搜尋...。
String locator 》當你在開發主題和外掛時,你經常會注意到某些文字被硬編碼在文件中,你需要對其進行修改,但你不知道該主題或外掛的名稱,更不知道要查找哪個文件。, 你可以...。
Search & Replace 》, 注意:此外掛未進行維護。, , 程式碼會繼續留在 SVN 和 Github 上,如果您有興趣。, 使用「Search & Replace」工具,您可以搜尋任何內容並以其他內容取...。
Relevanssi – A Better Search 》Relevanssi 取代了 WordPress 標準搜尋引擎,提供更好的搜尋體驗、豐富的功能和可配置的選項。使用 Relevanssi 會獲得更好的搜尋結果和呈現方式,你的使用者...。
Ivory Search – WordPress Search Plugin 》Ivory Search 是一個易於使用的 WordPress 高級搜尋插件。, 它可以增強預設的 WordPress 搜尋功能,還可以讓您創建新的自定義搜尋表單。, 使用 Ivory Search...。
Real-Time Find and Replace 》這個外掛允許你在頁面產生時,動態地替換主題和其他外掛的代碼和文字為你選擇的代碼和文字,然後再傳送頁面給使用者的瀏覽器。, 由於查找和替換是實時進行的...。
Ajax Search Lite – Live Search & Filter 》Ajax Search Lite 是一款 WordPress 的即時搜尋外掛程式。這款響應式的即時搜尋引擎將提供一個使用者友好的 AJAX 驅動搜尋表單 - 即時搜尋欄。你也可以使用分...。
Advanced Woo Search 》說明:, , Advanced Woo Search - 功能強大的 WooCommerce 搜索插件,支援 AJAX 搜索和搜尋結果頁面顯示。, 插件官方網站 | 功能列表 | 文檔, 主要功能, , 產...。
Search Exclude 》這個外掛能夠讓你勾選該頁面、文章或其他內容的複選框來將其排除在 WordPress 搜尋結果之外。, 支援快速和批次編輯。, 在外掛設置頁面中,您也可以看到所有被...。
Customizer Search 》是否使用使用 WordPress 自訂樣式主題?那你一定會喜歡這個外掛!不再花時間找尋設定,只需要搜尋你想要的設定項目,就可以立即前往該設定。, 適用於所有 Wor...。
SearchWP Live Ajax Search 》此 WordPress 外掛不需要SearchWP,但如果有的話就會使用它。在 searchwp.com 可以找到完整文檔。, 歡迎在 GitHub 上貢獻您的力量!https://github.com/jchri...。
Search & Filter 》Search & Filter 是一款簡單的 WordPress 搜尋和篩選外掛程式,是 WordPress 搜尋框的進階版。, 您可以透過類別、標籤、自訂分類、文章類型、發佈日期或...。
Better Find and Replace 》p>這個外掛提供了一個簡單的方式,可以搜尋目標字詞並且以你想要的字詞替換它。搜尋與替換的過程發生在網站在瀏覽器中呈現之前,不會影響到任何其他檔案或資...。
Disable Search 》此外掛可防止 WordPress 處理和允許任何來自網站前端的搜尋請求。具體來說,此外掛:, , 若主題使用標準的 get_search_form() 函式來顯示搜尋表單,則無法顯...。
ACF: Better Search 》此插件可為 WordPress 搜尋引擎添加額外功能,讓您可以在 Advanced Custom Fields 指定的欄位中搜尋內容。, 一切都是自動運作的,您無需添加任何額外的程式碼...。