You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@answer.apache.org by ku...@apache.org on 2023/12/14 09:14:55 UTC
(incubator-answer-plugins) branch main updated (a06f924 -> ca6051c)
This is an automated email from the ASF dual-hosted git repository.
kumfo pushed a change to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-answer-plugins.git
from a06f924 docs: change README, add project
new 7933d11 feat(search): add algolia search plugin
new ca6051c docs(README): update desc about algolia plugin
The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
README.md | 1 +
search-algolia/README.md | 25 +++
search-algolia/algolia.go | 248 +++++++++++++++++++++++++++
search-algolia/algoliaserverconfig.go | 55 ++++++
search-algolia/config.go | 97 +++++++++++
{storage-s3 => search-algolia}/go.mod | 7 +-
{storage-aliyunoss => search-algolia}/go.sum | 9 +-
search-algolia/i18n/en_US.yaml | 36 ++++
search-algolia/i18n/translation.go | 22 +++
search-algolia/i18n/zh_CN.yaml | 36 ++++
search-algolia/icon.go | 5 +
search-algolia/initsearch.go | 66 +++++++
search-algolia/sync.go | 63 +++++++
13 files changed, 662 insertions(+), 8 deletions(-)
create mode 100644 search-algolia/README.md
create mode 100644 search-algolia/algolia.go
create mode 100644 search-algolia/algoliaserverconfig.go
create mode 100644 search-algolia/config.go
copy {storage-s3 => search-algolia}/go.mod (91%)
copy {storage-aliyunoss => search-algolia}/go.sum (96%)
create mode 100644 search-algolia/i18n/en_US.yaml
create mode 100644 search-algolia/i18n/translation.go
create mode 100644 search-algolia/i18n/zh_CN.yaml
create mode 100644 search-algolia/icon.go
create mode 100644 search-algolia/initsearch.go
create mode 100644 search-algolia/sync.go
(incubator-answer-plugins) 02/02: docs(README): update desc about algolia plugin
Posted by ku...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
kumfo pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-answer-plugins.git
commit ca6051c6b3ca0c108687ba24dc43b4116b88a68d
Author: kumfo <ku...@sifou.com>
AuthorDate: Thu Dec 14 16:59:36 2023 +0800
docs(README): update desc about algolia plugin
---
README.md | 1 +
1 file changed, 1 insertion(+)
diff --git a/README.md b/README.md
index 0eea916..cf70d38 100644
--- a/README.md
+++ b/README.md
@@ -39,6 +39,7 @@ Support using search plugin to speed up the search of question answers. For exam
- [ ] [Elasticsearch](https://github.com/apache/incubator-answer-plugins/tree/main/search-elasticsearch)
- [ ] [Meilisearch](https://github.com/apache/incubator-answer-plugins/tree/main/search-meilisearch)
+- [ ] [Algolia](https://github.com/apache/incubator-answer-plugins/tree/main/search-algolia)
### Filter (coming soon)
(incubator-answer-plugins) 01/02: feat(search): add algolia search plugin
Posted by ku...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
kumfo pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-answer-plugins.git
commit 7933d11cc1c2043c4cda12270f37ea854a0c336c
Author: kumfo <ku...@sifou.com>
AuthorDate: Thu Dec 14 16:54:46 2023 +0800
feat(search): add algolia search plugin
---
search-algolia/README.md | 25 ++++
search-algolia/algolia.go | 248 ++++++++++++++++++++++++++++++++++
search-algolia/algoliaserverconfig.go | 55 ++++++++
search-algolia/config.go | 97 +++++++++++++
search-algolia/go.mod | 46 +++++++
search-algolia/go.sum | 146 ++++++++++++++++++++
search-algolia/i18n/en_US.yaml | 36 +++++
search-algolia/i18n/translation.go | 22 +++
search-algolia/i18n/zh_CN.yaml | 36 +++++
search-algolia/icon.go | 5 +
search-algolia/initsearch.go | 66 +++++++++
search-algolia/sync.go | 63 +++++++++
12 files changed, 845 insertions(+)
diff --git a/search-algolia/README.md b/search-algolia/README.md
new file mode 100644
index 0000000..6f4c299
--- /dev/null
+++ b/search-algolia/README.md
@@ -0,0 +1,25 @@
+# Algolia Search (preview)
+> Algolia is a hosted search engine, offering full-text, numerical, and faceted search, capable of delivering real-time
+> results from the first keystroke. Algolia's powerful API lets you quickly and seamlessly implement search within your
+> websites and mobile applications. Our search API powers billions of queries for thousands of companies every month,
+> delivering relevant results in under 100ms anywhere in the world.
+
+## How to use
+
+### Algolia Official website
+[Algolia](https://www.algolia.com/)
+
+### Build
+```bash
+./answer build --with github.com/apache/incubator-answer-plugins/search-algolia
+```
+
+### Configuration
+- `Application ID` - Your Algolia Application ID.
+- `Search-only API Key` - Your Algolia Search-only API Key (public).
+- `Admin API Key` - Your Algolia ADMIN API Key (kept private).
+- `Index name prefix` - This prefix will be prepended to your index names.
+- `Algolia logo` - Algolia requires that you keep the logo if you are using a free plan.
+
+### Note
+- If you have a large amount of data, it will be synchronized to algolia server auto when plugin configuration completed. If you need to know the specific progress, you need to check the console log information yourself.
diff --git a/search-algolia/algolia.go b/search-algolia/algolia.go
new file mode 100644
index 0000000..fe433ab
--- /dev/null
+++ b/search-algolia/algolia.go
@@ -0,0 +1,248 @@
+package algolia
+
+import (
+ "context"
+ "github.com/algolia/algoliasearch-client-go/v3/algolia/opt"
+ "github.com/algolia/algoliasearch-client-go/v3/algolia/search"
+ "github.com/apache/incubator-answer-plugins/search-algolia/i18n"
+ "github.com/apache/incubator-answer/plugin"
+ "strconv"
+ "strings"
+)
+
+type SearchAlgolia struct {
+ Config *AlgoliaSearchConfig
+ client *search.Client
+ syncer plugin.SearchSyncer
+}
+
+func init() {
+ uc := &SearchAlgolia{Config: &AlgoliaSearchConfig{}}
+ plugin.Register(uc)
+}
+
+func (s *SearchAlgolia) Info() plugin.Info {
+ return plugin.Info{
+ Name: plugin.MakeTranslator(i18n.InfoName),
+ SlugName: "algolia-search",
+ Description: plugin.MakeTranslator(i18n.InfoDescription),
+ Version: "0.0.1",
+ Author: "Answer Dev",
+ }
+}
+
+func (s *SearchAlgolia) Description() plugin.SearchDesc {
+ desc := plugin.SearchDesc{}
+ if s.Config.ShowLogo {
+ desc.Icon = icon
+ }
+ return desc
+}
+
+func (s *SearchAlgolia) RegisterSyncer(ctx context.Context, syncer plugin.SearchSyncer) {
+ s.syncer = syncer
+ s.sync()
+}
+
+func (s *SearchAlgolia) SearchContents(ctx context.Context, cond *plugin.SearchBasicCond) (res []plugin.SearchResult, total int64, err error) {
+ var (
+ filters = "status<10"
+ tagFilters []string
+ userIDFilter string
+ votesFilter string
+ )
+ if len(cond.TagIDs) > 0 {
+ for _, tagID := range cond.TagIDs {
+ tagFilters = append(tagFilters, "tags:"+tagID)
+ }
+ if len(tagFilters) > 0 {
+ filters += " AND " + strings.Join(tagFilters, " AND ")
+ }
+ }
+ if len(cond.UserID) > 0 {
+ userIDFilter = "userID:" + cond.UserID
+ filters += " AND " + userIDFilter
+ }
+ if cond.VoteAmount == 0 {
+ votesFilter = "votes=" + strconv.Itoa(cond.VoteAmount)
+ filters += " AND " + votesFilter
+ } else if cond.VoteAmount > 0 {
+ votesFilter = "votes>=" + strconv.Itoa(cond.VoteAmount)
+ filters += " AND " + votesFilter
+ }
+
+ var (
+ query = strings.TrimSpace(strings.Join(cond.Words, " "))
+ opts = []interface{}{
+ opt.AttributesToRetrieve("objectID", "type"),
+ opt.Filters(filters),
+ opt.Page(cond.Page - 1),
+ opt.HitsPerPage(cond.PageSize),
+ }
+ qres search.QueryRes
+ )
+
+ qres, err = s.getIndex(string(cond.Order)).Search(query, opts...)
+ for _, hit := range qres.Hits {
+ res = append(res, plugin.SearchResult{
+ ID: hit["objectID"].(string),
+ Type: hit["type"].(string),
+ })
+ }
+ total = int64(qres.NbHits)
+ return res, total, err
+}
+
+func (s *SearchAlgolia) SearchQuestions(ctx context.Context, cond *plugin.SearchBasicCond) (res []plugin.SearchResult, total int64, err error) {
+ var (
+ filters = "status<10 AND type:question"
+ tagFilters []string
+ userIDFilter string
+ viewsFilter string
+ answersFilter string
+ )
+ if len(cond.TagIDs) > 0 {
+ for _, tagID := range cond.TagIDs {
+ tagFilters = append(tagFilters, "tags:"+tagID)
+ }
+ if len(tagFilters) > 0 {
+ filters += " AND " + strings.Join(tagFilters, " AND ")
+ }
+ }
+ if cond.QuestionAccepted == plugin.AcceptedCondFalse {
+ userIDFilter = "hasAccepted:false"
+ filters += " AND " + userIDFilter
+ }
+
+ if cond.ViewAmount > -1 {
+ viewsFilter = "views>=" + strconv.Itoa(cond.ViewAmount)
+ filters += " AND " + viewsFilter
+ }
+
+ // check answers
+ if cond.AnswerAmount == 0 {
+ answersFilter = "answers=0"
+ filters += " AND " + answersFilter
+ } else if cond.AnswerAmount > 0 {
+ answersFilter = "answers>=" + strconv.Itoa(cond.AnswerAmount)
+ filters += " AND " + answersFilter
+ }
+
+ var (
+ query = strings.TrimSpace(strings.Join(cond.Words, " "))
+ opts = []interface{}{
+ opt.AttributesToRetrieve("objectID", "type"),
+ opt.Filters(filters),
+ opt.Page(cond.Page - 1),
+ opt.HitsPerPage(cond.PageSize),
+ }
+ qres search.QueryRes
+ )
+
+ qres, err = s.getIndex(string(cond.Order)).Search(query, opts...)
+ for _, hit := range qres.Hits {
+ res = append(res, plugin.SearchResult{
+ ID: hit["objectID"].(string),
+ Type: hit["type"].(string),
+ })
+ }
+
+ total = int64(qres.NbHits)
+ return res, total, err
+}
+
+func (s *SearchAlgolia) SearchAnswers(ctx context.Context, cond *plugin.SearchBasicCond) (res []plugin.SearchResult, total int64, err error) {
+ var (
+ filters = "status<10 AND type:answer"
+ tagFilters []string
+ userIDFilter string
+ questionIDFilter string
+ )
+ if len(cond.TagIDs) > 0 {
+ for _, tagID := range cond.TagIDs {
+ tagFilters = append(tagFilters, "tags:"+tagID)
+ }
+ if len(tagFilters) > 0 {
+ filters += " AND " + strings.Join(tagFilters, " AND ")
+ }
+ }
+ if cond.AnswerAccepted == plugin.AcceptedCondTrue {
+ userIDFilter = "hasAccepted=true"
+ filters += " AND " + userIDFilter
+ }
+
+ if len(cond.QuestionID) > 0 {
+ questionIDFilter = "questionID=" + cond.QuestionID
+ filters += questionIDFilter
+ }
+
+ var (
+ query = strings.TrimSpace(strings.Join(cond.Words, " "))
+ opts = []interface{}{
+ opt.AttributesToRetrieve("objectID", "type"),
+ opt.Filters(filters),
+ opt.Page(cond.Page - 1),
+ opt.HitsPerPage(cond.PageSize),
+ }
+ qres search.QueryRes
+ )
+
+ qres, err = s.getIndex(string(cond.Order)).Search(query, opts...)
+ for _, hit := range qres.Hits {
+ res = append(res, plugin.SearchResult{
+ ID: hit["objectID"].(string),
+ Type: hit["type"].(string),
+ })
+ }
+ total = int64(qres.NbHits)
+ return res, total, err
+}
+
+// UpdateContent updates the content to algolia server
+func (s *SearchAlgolia) UpdateContent(ctx context.Context, content *plugin.SearchContent) (err error) {
+ res, err := s.getIndex("").SaveObject(content)
+ if err != nil {
+ return
+ }
+ err = res.Wait()
+ return
+}
+
+// DeleteContent deletes the content
+func (s *SearchAlgolia) DeleteContent(ctx context.Context, contentID string) (err error) {
+ res, err := s.getIndex("").DeleteObject(contentID)
+ if err != nil {
+ return err
+ }
+ err = res.Wait()
+ return
+}
+
+// connect connect to algolia server
+func (s *SearchAlgolia) connect() (err error) {
+ s.client = search.NewClient(s.Config.APPID, s.Config.APIKey)
+ return
+}
+
+// init or create index
+func (s *SearchAlgolia) getIndex(order string) (index *search.Index) {
+ idx := s.getIndexName(order)
+ return s.client.InitIndex(idx)
+}
+
+func (s *SearchAlgolia) getIndexName(order string) string {
+ // main index
+ var idx = s.Config.Index
+ switch order {
+ case NewestIndex:
+ // the index of sort results by newest
+ idx = idx + "_" + NewestIndex
+ case ActiveIndex:
+ // the index of sort results by active
+ idx = idx + "_" + ActiveIndex
+ case ScoreIndex:
+ // the index of sort results by score
+ idx = idx + "_" + ScoreIndex
+ }
+ return idx
+}
diff --git a/search-algolia/algoliaserverconfig.go b/search-algolia/algoliaserverconfig.go
new file mode 100644
index 0000000..7c8426b
--- /dev/null
+++ b/search-algolia/algoliaserverconfig.go
@@ -0,0 +1,55 @@
+package algolia
+
+var AlgoliaSearchServerConfig = []byte(`
+{
+ "minWordSizefor1Typo": 4,
+ "minWordSizefor2Typos": 8,
+ "hitsPerPage": 20,
+ "maxValuesPerFacet": 100,
+ "searchableAttributes": [
+ "content",
+ "title"
+ ],
+ "numericAttributesToIndex": null,
+ "attributesToRetrieve": null,
+ "unretrievableAttributes": null,
+ "optionalWords": null,
+ "attributesForFaceting": [
+ "status",
+ "tags",
+ "type",
+ "user_id"
+ ],
+ "attributesToSnippet": null,
+ "attributesToHighlight": null,
+ "paginationLimitedTo": 1000,
+ "attributeForDistinct": null,
+ "exactOnSingleWordQuery": "attribute",
+ "ranking": [
+ "desc(active)",
+ "desc(score)",
+ "desc(created)",
+ "typo",
+ "geo",
+ "words",
+ "filters",
+ "proximity",
+ "attribute",
+ "exact",
+ "custom"
+ ],
+ "customRanking": [
+ "desc(title)",
+ "desc(content)"
+ ],
+ "separatorsToIndex": "",
+ "removeWordsIfNoResults": "none",
+ "queryType": "prefixLast",
+ "highlightPreTag": "<em>",
+ "highlightPostTag": "</em>",
+ "alternativesAsExact": [
+ "ignorePlurals",
+ "singleWordSynonym"
+ ]
+}
+`)
diff --git a/search-algolia/config.go b/search-algolia/config.go
new file mode 100644
index 0000000..b5129c1
--- /dev/null
+++ b/search-algolia/config.go
@@ -0,0 +1,97 @@
+package algolia
+
+import (
+ _ "embed"
+ "encoding/json"
+ "github.com/apache/incubator-answer-plugins/search-algolia/i18n"
+
+ "github.com/apache/incubator-answer/plugin"
+)
+
+var (
+ NewestIndex = "newest"
+ ActiveIndex = "active"
+ ScoreIndex = "score"
+)
+
+type AlgoliaSearchConfig struct {
+ APPID string `json:"app_id"`
+ PublicAPIKey string `json:"public_api_key"`
+ APIKey string `json:"api_key"`
+ Index string `json:"index"`
+ ShowLogo bool `json:"show_logo"`
+}
+
+// ConfigFields return config fields
+func (s *SearchAlgolia) ConfigFields() []plugin.ConfigField {
+ return []plugin.ConfigField{
+ {
+ Name: "app_id",
+ Type: plugin.ConfigTypeInput,
+ Title: plugin.MakeTranslator(i18n.ConfigAPPIDTitle),
+ Description: plugin.MakeTranslator(i18n.ConfigAPPIDDescription),
+ Required: true,
+ UIOptions: plugin.ConfigFieldUIOptions{
+ InputType: plugin.InputTypeText,
+ },
+ Value: s.Config.APPID,
+ },
+ {
+ Name: "public_api_key",
+ Type: plugin.ConfigTypeInput,
+ Title: plugin.MakeTranslator(i18n.ConfigPublicAPIKeyTitle),
+ Description: plugin.MakeTranslator(i18n.ConfigPublicAPIKeyDescription),
+ Required: true,
+ UIOptions: plugin.ConfigFieldUIOptions{
+ InputType: plugin.InputTypePassword,
+ },
+ Value: s.Config.PublicAPIKey,
+ },
+ {
+ Name: "api_key",
+ Type: plugin.ConfigTypeInput,
+ Title: plugin.MakeTranslator(i18n.ConfigAPIKeyTitle),
+ Description: plugin.MakeTranslator(i18n.ConfigAPIKeyDescription),
+ Required: true,
+ UIOptions: plugin.ConfigFieldUIOptions{
+ InputType: plugin.InputTypePassword,
+ },
+ Value: s.Config.APIKey,
+ },
+ {
+ Name: "index",
+ Type: plugin.ConfigTypeInput,
+ Title: plugin.MakeTranslator(i18n.ConfigIndexTitle),
+ Description: plugin.MakeTranslator(i18n.ConfigIndexDescription),
+ Required: true,
+ UIOptions: plugin.ConfigFieldUIOptions{
+ InputType: plugin.InputTypeText,
+ },
+ Value: s.Config.Index,
+ },
+ {
+ Name: "show_logo",
+ Type: plugin.ConfigTypeSwitch,
+ Title: plugin.MakeTranslator(i18n.ConfigShowLogoTitle),
+ Description: plugin.MakeTranslator(i18n.ConfigShowLogoDescription),
+ UIOptions: plugin.ConfigFieldUIOptions{
+ Label: plugin.MakeTranslator(i18n.ConfigShowLogoLabel),
+ },
+ Value: s.Config.ShowLogo,
+ },
+ }
+}
+
+// ConfigReceiver receive config from admin
+func (s *SearchAlgolia) ConfigReceiver(config []byte) error {
+ c := &AlgoliaSearchConfig{}
+ _ = json.Unmarshal(config, c)
+ s.Config = c
+ err := s.connect()
+ if err != nil {
+ return err
+ }
+ // if config update, re-init settings
+ err = s.initSettings()
+ return err
+}
diff --git a/search-algolia/go.mod b/search-algolia/go.mod
new file mode 100644
index 0000000..7e71b0a
--- /dev/null
+++ b/search-algolia/go.mod
@@ -0,0 +1,46 @@
+module github.com/apache/incubator-answer-plugins/search-algolia
+
+go 1.19
+
+require (
+ github.com/algolia/algoliasearch-client-go/v3 v3.29.2
+ github.com/apache/incubator-answer v1.2.1-0.20231101064835-a458f3409c91
+ github.com/segmentfault/pacman v1.0.5-0.20230822083413-c0075a2d401f
+)
+
+require (
+ github.com/LinkinStars/go-i18n/v2 v2.2.2 // indirect
+ github.com/aymerick/douceur v0.2.0 // indirect
+ github.com/bytedance/sonic v1.9.1 // indirect
+ github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311 // indirect
+ github.com/gabriel-vasile/mimetype v1.4.2 // indirect
+ github.com/gin-contrib/sse v0.1.0 // indirect
+ github.com/gin-gonic/gin v1.9.1 // indirect
+ github.com/go-playground/locales v0.14.1 // indirect
+ github.com/go-playground/universal-translator v0.18.1 // indirect
+ github.com/go-playground/validator/v10 v10.14.0 // indirect
+ github.com/goccy/go-json v0.10.2 // indirect
+ github.com/google/wire v0.5.0 // indirect
+ github.com/gorilla/css v1.0.0 // indirect
+ github.com/json-iterator/go v1.1.12 // indirect
+ github.com/klauspost/cpuid/v2 v2.2.4 // indirect
+ github.com/kr/text v0.2.0 // indirect
+ github.com/leodido/go-urn v1.2.4 // indirect
+ github.com/mattn/go-isatty v0.0.19 // indirect
+ github.com/microcosm-cc/bluemonday v1.0.21 // indirect
+ github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
+ github.com/modern-go/reflect2 v1.0.2 // indirect
+ github.com/pelletier/go-toml/v2 v2.0.8 // indirect
+ github.com/segmentfault/pacman/contrib/i18n v0.0.0-20230516093754-b76aef1c1150 // indirect
+ github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
+ github.com/ugorji/go/codec v1.2.11 // indirect
+ golang.org/x/arch v0.3.0 // indirect
+ golang.org/x/crypto v0.13.0 // indirect
+ golang.org/x/net v0.15.0 // indirect
+ golang.org/x/sys v0.12.0 // indirect
+ golang.org/x/text v0.13.0 // indirect
+ google.golang.org/protobuf v1.30.0 // indirect
+ gopkg.in/yaml.v2 v2.4.0 // indirect
+ gopkg.in/yaml.v3 v3.0.1 // indirect
+ sigs.k8s.io/yaml v1.3.0 // indirect
+)
diff --git a/search-algolia/go.sum b/search-algolia/go.sum
new file mode 100644
index 0000000..c1aacd0
--- /dev/null
+++ b/search-algolia/go.sum
@@ -0,0 +1,146 @@
+github.com/BurntSushi/toml v1.0.0 h1:dtDWrepsVPfW9H/4y7dDgFc2MBUSeJhlaDtK13CxFlU=
+github.com/BurntSushi/toml v1.0.0/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ=
+github.com/LinkinStars/go-i18n/v2 v2.2.2 h1:ZfjpzbW13dv6btv3RALKZkpN9A+7K1JA//2QcNeWaxU=
+github.com/LinkinStars/go-i18n/v2 v2.2.2/go.mod h1:hLglSJ4/3M0Y7ZVcoEJI+OwqkglHCA32DdjuJJR2LbM=
+github.com/algolia/algoliasearch-client-go/v3 v3.29.2 h1:lmAD/gNui2TLoT8az22ECr056EjoBR0RJQssNezyniQ=
+github.com/algolia/algoliasearch-client-go/v3 v3.29.2/go.mod h1:i7tLoP7TYDmHX3Q7vkIOL4syVse/k5VJ+k0i8WqFiJk=
+github.com/apache/incubator-answer v1.2.1-0.20231101064835-a458f3409c91 h1:9XdFA/5tLRI2Tc0MJ3eeQgI8Yl1DS+QgWOnKnMLKU5M=
+github.com/apache/incubator-answer v1.2.1-0.20231101064835-a458f3409c91/go.mod h1:x1L7qbTIx0NstjPFvYduzazhS4x3e1bpCoootQdrVms=
+github.com/aymerick/douceur v0.2.0 h1:Mv+mAeH1Q+n9Fr+oyamOlAkUNPWPlA8PPGR0QAaYuPk=
+github.com/aymerick/douceur v0.2.0/go.mod h1:wlT5vV2O3h55X9m7iVYN0TBM0NH/MmbLnd30/FjWUq4=
+github.com/bytedance/sonic v1.5.0/go.mod h1:ED5hyg4y6t3/9Ku1R6dU/4KyJ48DZ4jPhfY1O2AihPM=
+github.com/bytedance/sonic v1.9.1 h1:6iJ6NqdoxCDr6mbY8h18oSO+cShGSMRGCEo7F2h0x8s=
+github.com/bytedance/sonic v1.9.1/go.mod h1:i736AoUSYt75HyZLoJW9ERYxcy6eaN6h4BZXU064P/U=
+github.com/chenzhuoyu/base64x v0.0.0-20211019084208-fb5309c8db06/go.mod h1:DH46F32mSOjUmXrMHnKwZdA8wcEefY7UVqBKYGjpdQY=
+github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311 h1:qSGYFH7+jGhDF8vLC+iwCD4WpbV1EBDSzWkJODFLams=
+github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311/go.mod h1:b583jCggY9gE99b6G5LEC39OIiVsWj+R97kbl5odCEk=
+github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
+github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
+github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
+github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
+github.com/gabriel-vasile/mimetype v1.4.2 h1:w5qFW6JKBz9Y393Y4q372O9A7cUSequkh1Q7OhCmWKU=
+github.com/gabriel-vasile/mimetype v1.4.2/go.mod h1:zApsH/mKG4w07erKIaJPFiX0Tsq9BFQgN3qGY5GnNgA=
+github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE=
+github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI=
+github.com/gin-gonic/gin v1.9.1 h1:4idEAncQnU5cB7BeOkPtxjfCSye0AAm1R0RVIqJ+Jmg=
+github.com/gin-gonic/gin v1.9.1/go.mod h1:hPrL7YrpYKXt5YId3A/Tnip5kqbEAP+KLuI3SUcPTeU=
+github.com/go-playground/assert/v2 v2.2.0 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s=
+github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/oXslEjJA=
+github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY=
+github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY=
+github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY=
+github.com/go-playground/validator/v10 v10.14.0 h1:vgvQWe3XCz3gIeFDm/HnTIbj6UGmg/+t63MyGU2n5js=
+github.com/go-playground/validator/v10 v10.14.0/go.mod h1:9iXMNT7sEkjXb0I+enO7QXmzG6QCsPWY4zveKFVRSyU=
+github.com/goccy/go-json v0.10.2 h1:CrxCmQqYDkv1z7lO7Wbh2HN93uovUHgrECaO5ZrCXAU=
+github.com/goccy/go-json v0.10.2/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I=
+github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
+github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
+github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU=
+github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
+github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
+github.com/google/subcommands v1.0.1/go.mod h1:ZjhPrFU+Olkh9WazFPsl27BQ4UPiG37m3yTrtFlrHVk=
+github.com/google/wire v0.5.0 h1:I7ELFeVBr3yfPIcc8+MWvrjk+3VjbcSzoXm3JVa+jD8=
+github.com/google/wire v0.5.0/go.mod h1:ngWDr9Qvq3yZA10YrxfyGELY/AFWGVpy9c1LTRi1EoU=
+github.com/gorilla/css v1.0.0 h1:BQqNyPTi50JCFMTw/b67hByjMVXZRwGha6wxVGkeihY=
+github.com/gorilla/css v1.0.0/go.mod h1:Dn721qIggHpt4+EFCcTLTU/vk5ySda2ReITrtgBl60c=
+github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
+github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
+github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg=
+github.com/klauspost/cpuid/v2 v2.2.4 h1:acbojRNwl3o09bUq+yDCtZFc1aiwaAAxtcn8YkZXnvk=
+github.com/klauspost/cpuid/v2 v2.2.4/go.mod h1:RVVoqg1df56z8g3pUjL/3lE5UfnlrJX8tyFgg4nqhuY=
+github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0=
+github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
+github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
+github.com/leodido/go-urn v1.2.4 h1:XlAE/cm/ms7TE/VMVoduSpNBoyc2dOxHs5MZSwAN63Q=
+github.com/leodido/go-urn v1.2.4/go.mod h1:7ZrI8mTSeBSHl/UaRyKQW1qZeMgak41ANeCNaVckg+4=
+github.com/mattn/go-isatty v0.0.19 h1:JITubQf0MOLdlGRuRq+jtsDlekdYPia9ZFsB8h/APPA=
+github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
+github.com/microcosm-cc/bluemonday v1.0.21 h1:dNH3e4PSyE4vNX+KlRGHT5KrSvjeUkoNPwEORjffHJg=
+github.com/microcosm-cc/bluemonday v1.0.21/go.mod h1:ytNkv4RrDrLJ2pqlsSI46O6IVXmZOBBD4SaJyDwwTkM=
+github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
+github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg=
+github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
+github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M=
+github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
+github.com/pelletier/go-toml/v2 v2.0.8 h1:0ctb6s9mE31h0/lhu+J6OPmVeDxJn+kYnJc2jZR9tGQ=
+github.com/pelletier/go-toml/v2 v2.0.8/go.mod h1:vuYfssBdrU2XDZ9bYydBu6t+6a6PYNcZljzZR9VXg+4=
+github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
+github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
+github.com/rogpeppe/go-internal v1.8.0 h1:FCbCCtXNOY3UtUuHUYaghJg4y7Fd14rXifAYUAtL9R8=
+github.com/segmentfault/pacman v1.0.5-0.20230822083413-c0075a2d401f h1:9f2Bjf6bdMvNyUop32wAGJCdp+Jdm/d6nKBYvFvkRo0=
+github.com/segmentfault/pacman v1.0.5-0.20230822083413-c0075a2d401f/go.mod h1:5lNp5REd8QMThmBUvR3Fi9Y3AsOB4GRq7soCB4QLqOs=
+github.com/segmentfault/pacman/contrib/i18n v0.0.0-20230516093754-b76aef1c1150 h1:OEuW1D7RGDE0CZDr0oGMw9Eiq7fAbD9C4WMrvSixamk=
+github.com/segmentfault/pacman/contrib/i18n v0.0.0-20230516093754-b76aef1c1150/go.mod h1:7QcRmnV7OYq4hNOOCWXT5HXnN/u756JUsqIW0Bw8n9E=
+github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
+github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
+github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
+github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
+github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
+github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
+github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
+github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
+github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
+github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
+github.com/stretchr/testify v1.8.3/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
+github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
+github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS4MhqMhdFk5YI=
+github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08=
+github.com/ugorji/go/codec v1.2.11 h1:BMaWp1Bb6fHwEtbplGBGJ498wD+LKlNSl25MjdZY4dU=
+github.com/ugorji/go/codec v1.2.11/go.mod h1:UNopzCgEMSXjBc6AOMqYvWC1ktqTAfzJZUZgYf6w6lg=
+github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
+golang.org/x/arch v0.0.0-20210923205945-b76863e36670/go.mod h1:5om86z9Hs0C8fWVUuoMHwpExlXzs5Tkyp9hOrfG7pp8=
+golang.org/x/arch v0.3.0 h1:02VY4/ZcO/gBOH6PUaoiptASxtXU10jazRCP865E97k=
+golang.org/x/arch v0.3.0/go.mod h1:5om86z9Hs0C8fWVUuoMHwpExlXzs5Tkyp9hOrfG7pp8=
+golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
+golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
+golang.org/x/crypto v0.13.0 h1:mvySKfSWJ+UKUii46M40LOvyWfN0s2U+46/jDd0e6Ck=
+golang.org/x/crypto v0.13.0/go.mod h1:y6Z2r+Rw4iayiXXAIxJIDAJ1zMW4yaTpebo8fPOliYc=
+golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
+golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
+golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
+golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
+golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
+golang.org/x/net v0.15.0 h1:ugBLEUaxABaB5AJqW9enI0ACdci2RUd4eP51NTBvuJ8=
+golang.org/x/net v0.15.0/go.mod h1:idbUs1IY1+zTqbi8yxTbhexhEEk5ur9LInksu6HrEpk=
+golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
+golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
+golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
+golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
+golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
+golang.org/x/sys v0.0.0-20220704084225-05e143d24a9e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
+golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
+golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
+golang.org/x/sys v0.12.0 h1:CM0HF96J0hcLAwsHPJZjfdNzs0gftsLfgKt57wWHJ0o=
+golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
+golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
+golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
+golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
+golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
+golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
+golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
+golang.org/x/text v0.13.0 h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k=
+golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
+golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
+golang.org/x/tools v0.0.0-20190422233926-fe54fb35175b/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
+golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
+golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
+golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
+golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4=
+golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
+google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
+google.golang.org/protobuf v1.30.0 h1:kPPoIgf3TsEvrm0PFe15JQ+570QVxYzEvvHqChK+cng=
+google.golang.org/protobuf v1.30.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
+gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
+gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
+gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
+gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
+gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
+gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
+gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
+gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
+gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
+gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
+rsc.io/pdf v0.1.1/go.mod h1:n8OzWcQ6Sp37PL01nO98y4iUCRdTGarVfzxY20ICaU4=
+sigs.k8s.io/yaml v1.3.0 h1:a2VclLzOGrwOHDiV8EfBGhvjHvP46CtW5j6POvhYGGo=
+sigs.k8s.io/yaml v1.3.0/go.mod h1:GeOyir5tyXNByN85N/dRIT9es5UQNerPYEKK56eTBm8=
diff --git a/search-algolia/i18n/en_US.yaml b/search-algolia/i18n/en_US.yaml
new file mode 100644
index 0000000..cc5fa62
--- /dev/null
+++ b/search-algolia/i18n/en_US.yaml
@@ -0,0 +1,36 @@
+plugin:
+ algolia_search:
+ backend:
+ info:
+ name:
+ other: Algolia Search
+ description:
+ other: Use Algolia as a search engine.
+ config:
+ app_id:
+ title:
+ other: Application ID
+ description:
+ other: Your Algolia Application ID. <a href="https://dashboard.algolia.com/account/api-keys/all" target="_blank">Manage Your API keys</a>
+ public_api_key:
+ title:
+ other: Search-only API Key
+ description:
+ other: Your Algolia Search-only API Key (public).
+ api_key:
+ title:
+ other: Admin API Key
+ description:
+ other: Your Algolia ADMIN API Key (kept private).
+ index:
+ title:
+ other: Index name prefix
+ description:
+ other: This prefix will be prepended to your index names.
+ show_logo:
+ title:
+ other: Algolia logo
+ description:
+ other: Algolia requires that you keep the logo if you are using a free plan.
+ label:
+ other: Show Algolia logo
\ No newline at end of file
diff --git a/search-algolia/i18n/translation.go b/search-algolia/i18n/translation.go
new file mode 100644
index 0000000..23a9eed
--- /dev/null
+++ b/search-algolia/i18n/translation.go
@@ -0,0 +1,22 @@
+package i18n
+
+const (
+ InfoName = "plugin.algolia_search.backend.info.name"
+ InfoDescription = "plugin.algolia_search.backend.info.description"
+
+ ConfigAPPIDTitle = "plugin.algolia_search.backend.config.app_id.title"
+ ConfigAPPIDDescription = "plugin.algolia_search.backend.config.app_id.description"
+
+ ConfigPublicAPIKeyTitle = "plugin.algolia_search.backend.config.public_api_key.title"
+ ConfigPublicAPIKeyDescription = "plugin.algolia_search.backend.config.public_api_key.description"
+
+ ConfigAPIKeyTitle = "plugin.algolia_search.backend.config.api_key.title"
+ ConfigAPIKeyDescription = "plugin.algolia_search.backend.config.api_key.description"
+
+ ConfigIndexTitle = "plugin.algolia_search.backend.config.index.title"
+ ConfigIndexDescription = "plugin.algolia_search.backend.config.index.description"
+
+ ConfigShowLogoTitle = "plugin.algolia_search.backend.config.show_logo.title"
+ ConfigShowLogoDescription = "plugin.algolia_search.backend.config.show_logo.description"
+ ConfigShowLogoLabel = "plugin.algolia_search.backend.config.show_logo.label"
+)
diff --git a/search-algolia/i18n/zh_CN.yaml b/search-algolia/i18n/zh_CN.yaml
new file mode 100644
index 0000000..3ae7921
--- /dev/null
+++ b/search-algolia/i18n/zh_CN.yaml
@@ -0,0 +1,36 @@
+plugin:
+ algolia_search:
+ backend:
+ info:
+ name:
+ other: Algolia 搜索
+ description:
+ other: 使用 Algolia 作为搜索引擎.
+ config:
+ app_id:
+ title:
+ other: Application ID
+ description:
+ other: 你的 Algolia Application ID. <a href="https://dashboard.algolia.com/account/api-keys/all" target="_blank">管理你的 API keys</a>
+ public_api_key:
+ title:
+ other: Search-only API Key
+ description:
+ other: 你的 Algolia Search-only API Key (公有)。
+ api_key:
+ title:
+ other: 管理 API Key
+ description:
+ other: 你的 Algolia ADMIN API Key (请保持私密)。
+ index:
+ title:
+ other: 索引名称前缀
+ description:
+ other: 这个前缀将预追加到你的索引名称之前。
+ show_logo:
+ title:
+ other: Algolia logo
+ description:
+ other: 如果你使用的是免费版本,Algolia 要求你保留 Algolia 的 logo。
+ label:
+ other: 展示 Algolia logo
\ No newline at end of file
diff --git a/search-algolia/icon.go b/search-algolia/icon.go
new file mode 100644
index 0000000..7764556
--- /dev/null
+++ b/search-algolia/icon.go
@@ -0,0 +1,5 @@
+package algolia
+
+const (
+ icon = `PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSI5MyIgaGVpZ2h0PSIyMSIgdmlld0JveD0iMCAwIDkzIDIxIiBmaWxsPSJub25lIj4KPGcgY2xpcC1wYXRoPSJ1cmwoI2NsaXAwXzE3MTczXzgwMzEpIj4KPHBhdGggZmlsbC1ydWxlPSJldmVub2RkIiBjbGlwLXJ1bGU9ImV2ZW5vZGQiIGQ9Ik00NC45NTU5IDExLjU2MjZWMC4yNDgyMDVDNDQuOTU1OSAwLjA5NTc0NTQgNDQuODE5OCAtMC4wMjAxNzQ2IDQ0LjY2OTUgMC4wMDMzNDU0TDQyLjU1MDIgMC4zMzY4MjVDNDIuNDI5NiAwLjM1NTcyNSA0Mi4zNDA2IDAuNDU5ODg1IDQyLjM0MDYgMC41ODIxMDVMNDIuMzQ3NyAxMi4wNTczQzQyLjM0NzcgMTIuNiA [...]
+)
diff --git a/search-algolia/initsearch.go b/search-algolia/initsearch.go
new file mode 100644
index 0000000..0b9eca4
--- /dev/null
+++ b/search-algolia/initsearch.go
@@ -0,0 +1,66 @@
+package algolia
+
+import (
+ "github.com/algolia/algoliasearch-client-go/v3/algolia/opt"
+ "github.com/algolia/algoliasearch-client-go/v3/algolia/search"
+)
+
+// initSettings update algolia search settings
+func (s *SearchAlgolia) initSettings() (err error) {
+ var (
+ settings = search.Settings{}
+ )
+ err = settings.UnmarshalJSON(AlgoliaSearchServerConfig)
+ if err != nil {
+ return
+ }
+
+ // point virtual index to sort
+ settings.Replicas = opt.Replicas(
+ "virtual("+s.getIndexName(NewestIndex)+")",
+ "virtual("+s.getIndexName(ActiveIndex)+")",
+ "virtual("+s.getIndexName(ScoreIndex)+")",
+ )
+
+ _, err = s.getIndex("").SetSettings(settings, opt.ForwardToReplicas(true))
+ if err != nil {
+ return
+ }
+ err = s.initVirtualReplicaSetting()
+ return
+}
+
+// initVirtualReplicaSetting init virtual index replica setting
+func (s *SearchAlgolia) initVirtualReplicaSetting() (err error) {
+
+ _, err = s.getIndex(NewestIndex).SetSettings(search.Settings{
+ CustomRanking: opt.CustomRanking(
+ "desc(created)",
+ "desc(content)",
+ "desc(title)"),
+ })
+ if err != nil {
+ return
+ }
+
+ _, err = s.getIndex(ActiveIndex).SetSettings(search.Settings{
+ CustomRanking: opt.CustomRanking(
+ "desc(active)",
+ "desc(content)",
+ "desc(title)"),
+ })
+ if err != nil {
+ return
+ }
+
+ _, err = s.getIndex(ScoreIndex).SetSettings(search.Settings{
+ CustomRanking: opt.CustomRanking(
+ "desc(score)",
+ "desc(content)",
+ "desc(title)"),
+ })
+ if err != nil {
+ return
+ }
+ return
+}
diff --git a/search-algolia/sync.go b/search-algolia/sync.go
new file mode 100644
index 0000000..dc4657f
--- /dev/null
+++ b/search-algolia/sync.go
@@ -0,0 +1,63 @@
+package algolia
+
+import (
+ "context"
+ "github.com/apache/incubator-answer/plugin"
+ "github.com/segmentfault/pacman/log"
+)
+
+func (s *SearchAlgolia) sync() {
+ var page, pageSize = 1, 100
+ go func() {
+ log.Info("algolia: start sync questions...")
+ page = 1
+ for {
+ log.Infof("algolia: sync question page %d, page size %d", page, pageSize)
+ questionList, err := s.syncer.GetQuestionsPage(context.TODO(), page, pageSize)
+ if err != nil {
+ log.Error("algolia: sync questions error", err)
+ break
+ }
+ if len(questionList) == 0 {
+ break
+ }
+ err = s.batchUpdateContent(context.TODO(), questionList)
+ if err != nil {
+ log.Error("algolia: sync questions error", err)
+ }
+ page += 1
+ }
+
+ log.Info("algolia: start sync answers...")
+ page = 1
+ for {
+ log.Infof("algolia: sync answer page %d, page size %d", page, pageSize)
+ answerList, err := s.syncer.GetAnswersPage(context.TODO(), page, pageSize)
+ if err != nil {
+ log.Error("algolia: sync answers error", err)
+ break
+ }
+
+ if len(answerList) == 0 {
+ break
+ }
+
+ err = s.batchUpdateContent(context.TODO(), answerList)
+ if err != nil {
+ log.Error("algolia: sync answers error", err)
+ }
+
+ page += 1
+ }
+ log.Info("algolia: sync done")
+ }()
+}
+
+func (s *SearchAlgolia) batchUpdateContent(ctx context.Context, contents []*plugin.SearchContent) (err error) {
+ res, err := s.getIndex("").SaveObjects(contents)
+ if err != nil {
+ return
+ }
+ err = res.Wait()
+ return
+}