Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/wpperformance/wp-performance-meilisearch
Meilisearch implementation for WordPress
https://github.com/wpperformance/wp-performance-meilisearch
meilisearch wordpress
Last synced: 13 days ago
JSON representation
Meilisearch implementation for WordPress
- Host: GitHub
- URL: https://github.com/wpperformance/wp-performance-meilisearch
- Owner: wpperformance
- Created: 2023-04-06T19:07:25.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2023-04-06T19:07:43.000Z (almost 2 years ago)
- Last Synced: 2024-11-12T05:12:40.931Z (2 months ago)
- Topics: meilisearch, wordpress
- Language: PHP
- Homepage:
- Size: 10.7 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Meilisearch implementation for WordPress
## WP-CLI
This plugin add a wp-cli command for save all post
```
wp meilisearch reindex_post
```## update filterable fields
```
wp meilisearch update_filterable
```## Hook
Update index of meilisearch when a post has added, updated or deleted
## Config
Add in wp-config.php :
```
define('MEILISEARCH_URL', 'XXX');
define('MEILISEARCH_KEY_PUBLIC', 'XXX');
define('MEILISEARCH_KEY_SECRET', 'XXX');```
## JS
```
npm add @meilisearch/instant-meilisearch instantsearch.js
```The vars `MEILISEARCH_URL`, `MEILISEARCH_KEY_PUBLIC` and `MEILISEARCH_APP_INDEX` are shared across the page for use in javascript script.
Example of use :
```html
```
or pattern
```html
```
```js
import { instantMeiliSearch } from '@meilisearch/instant-meilisearch'
import instantsearch from 'instantsearch.js'
import { searchBox, hits, refinementList } from 'instantsearch.js/es/widgets'const initSearch = () => {
const search = instantsearch({
indexName: MEILISEARCH_APP_INDEX,
numberLocale: 'fr',
searchClient: instantMeiliSearch(MEILISEARCH_URL, MEILISEARCH_KEY_PUBLIC),
searchFunction(helper) {
// Ensure we only trigger a search when there's a query
if (helper.state.query && helper.state.query !== '') {
document.getElementById('hits').removeAttribute('hidden')
helper.search()
} else {
document.getElementById('hits').setAttribute('hidden', true)
}
},
})search.addWidgets([
searchBox({
container: '#searchbox',
}),
refinementList({
container: '#tag-list',
attribute: 'tags',
limit: 5,
showMore: true,
}),
hits({
container: '#hits',
templates: {
item: `
{{#helpers.highlight}}
{ "attribute": "title", "highlightedTagName": "mark" }
{{/helpers.highlight}}
{{#content}}
{{#helpers.highlight}}{ "attribute": "excerpt", "highlightedTagName": "mark" }{{/helpers.highlight}}
{{/content}}
`,
},
}),
])search.start()
}export default initSearch
```## Doc
- [https://github.com/meilisearch/instant-meilisearch](https://github.com/meilisearch/instant-meilisearch)