Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Authors controller #112

Merged
merged 9 commits into from
Dec 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions internal/index/author.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package index

type Author struct {
Slug string
Name string
Type string
}

// BleveType is part of the bleve.Classifier interface and its purpose is to tell the indexer
// the type of the document, which will be used to decide which analyzer will parse it.
func (a Author) BleveType() string {
return "author"
}
23 changes: 14 additions & 9 deletions internal/index/bleve.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,12 @@ import (

// Version identifies the mapping used for indexing. Any changes in the mapping requires an increase
// of version, to signal that a new index needs to be created.
const Version = "v3"
const Version = "v4"

const (
TypeDocument = "document"
TypeAuthor = "author"
)

// Metadata fields
var (
Expand Down Expand Up @@ -111,29 +116,29 @@ func CreateMapping() mapping.IndexMapping {

indexMapping.AddDocumentMapping(lang, bleve.NewDocumentMapping())
indexMapping.TypeMapping[lang].DefaultAnalyzer = lang
indexMapping.TypeMapping[lang].AddFieldMappingsAt("Slug", keywordFieldMapping)
indexMapping.TypeMapping[lang].AddFieldMappingsAt("Title", noStopWordsTextFieldMapping)
indexMapping.TypeMapping[lang].AddFieldMappingsAt("Authors", simpleTextFieldMapping)
indexMapping.TypeMapping[lang].AddFieldMappingsAt("AuthorsSlugs", keywordFieldMapping)
indexMapping.TypeMapping[lang].AddFieldMappingsAt("Description", textFieldMapping)
indexMapping.TypeMapping[lang].AddFieldMappingsAt("Subjects", textFieldMapping)
indexMapping.TypeMapping[lang].AddFieldMappingsAt("SubjectsSlugs", keywordFieldMapping)
indexMapping.TypeMapping[lang].AddFieldMappingsAt("Series", noStopWordsTextFieldMapping)
indexMapping.TypeMapping[lang].AddFieldMappingsAt("Slug", keywordFieldMapping)
indexMapping.TypeMapping[lang].AddFieldMappingsAt("SeriesEq", keywordFieldMapping)
indexMapping.TypeMapping[lang].AddFieldMappingsAt("AuthorsEq", keywordFieldMapping)
indexMapping.TypeMapping[lang].AddFieldMappingsAt("SubjectsEq", keywordFieldMapping)
indexMapping.TypeMapping[lang].AddFieldMappingsAt("SeriesSlug", keywordFieldMapping)
indexMapping.TypeMapping[lang].AddFieldMappingsAt("Language", keywordFieldMappingNotIndexable)
indexMapping.TypeMapping[lang].AddFieldMappingsAt("Year", keywordFieldMappingNotIndexable)
}

indexMapping.DefaultMapping.DefaultAnalyzer = defaultAnalyzer
indexMapping.DefaultMapping.AddFieldMappingsAt("Slug", keywordFieldMapping)
indexMapping.DefaultMapping.AddFieldMappingsAt("Title", simpleTextFieldMapping)
indexMapping.DefaultMapping.AddFieldMappingsAt("Authors", simpleTextFieldMapping)
indexMapping.DefaultMapping.AddFieldMappingsAt("AuthorsSlugs", keywordFieldMapping)
indexMapping.DefaultMapping.AddFieldMappingsAt("Description", simpleTextFieldMapping)
indexMapping.DefaultMapping.AddFieldMappingsAt("Subjects", simpleTextFieldMapping)
indexMapping.DefaultMapping.AddFieldMappingsAt("SubjectsSlugs", keywordFieldMapping)
indexMapping.DefaultMapping.AddFieldMappingsAt("Series", simpleTextFieldMapping)
indexMapping.DefaultMapping.AddFieldMappingsAt("Slug", keywordFieldMapping)
indexMapping.DefaultMapping.AddFieldMappingsAt("SeriesEq", keywordFieldMapping)
indexMapping.DefaultMapping.AddFieldMappingsAt("AuthorsEq", keywordFieldMapping)
indexMapping.DefaultMapping.AddFieldMappingsAt("SubjectsEq", keywordFieldMapping)
indexMapping.DefaultMapping.AddFieldMappingsAt("SeriesSlug", keywordFieldMapping)
indexMapping.DefaultMapping.AddFieldMappingsAt("Language", keywordFieldMappingNotIndexable)
indexMapping.DefaultMapping.AddFieldMappingsAt("Year", keywordFieldMappingNotIndexable)

Expand Down
Loading
Loading