photoprism/internal/entity/keyword_fixtures.go
Michael Mayer 24eff21aa4 Search: Default to photo names and keywords #1517 #1560
Default to photo name when search term is too short or on the stop list.
Search full text index otherwise, which now include names of people
(requires reindexing).
2021-09-29 20:09:34 +02:00

54 lines
904 B
Go

package entity
type KeywordMap map[string]Keyword
func (m KeywordMap) Get(name string) Keyword {
if result, ok := m[name]; ok {
return result
}
return *NewKeyword(name)
}
func (m KeywordMap) Pointer(name string) *Keyword {
if result, ok := m[name]; ok {
return &result
}
return NewKeyword(name)
}
var KeywordFixtures = KeywordMap{
"bridge": {
ID: 1000000,
Keyword: "bridge",
Skip: false,
},
"beach": {
ID: 1000001,
Keyword: "beach",
Skip: false,
},
"flower": {
ID: 1000002,
Keyword: "flower",
Skip: false,
},
"kuh": {
ID: 1000003,
Keyword: "kuh",
Skip: false,
},
"actress": {
ID: 1000004,
Keyword: "actress",
Skip: false,
},
}
// CreateKeywordFixtures inserts known entities into the database for testing.
func CreateKeywordFixtures() {
for _, entity := range KeywordFixtures {
Db().Create(&entity)
}
}