133 lines
3.2 KiB
Go
133 lines
3.2 KiB
Go
|
|
package elasticsearch
|
||
|
|
|
||
|
|
// Index names (F361, F362)
|
||
|
|
const (
|
||
|
|
IdxTracks = "tracks"
|
||
|
|
IdxUsers = "users"
|
||
|
|
IdxPlaylists = "playlists"
|
||
|
|
)
|
||
|
|
|
||
|
|
// Track mapping: title, artist, tags, genre, description (F361)
|
||
|
|
// Multi-field with fuzziness for typo tolerance (F364)
|
||
|
|
const tracksMapping = `{
|
||
|
|
"settings": {
|
||
|
|
"analysis": {
|
||
|
|
"analyzer": {
|
||
|
|
"veza_text": {
|
||
|
|
"type": "custom",
|
||
|
|
"tokenizer": "standard",
|
||
|
|
"filter": ["lowercase", "asciifolding"]
|
||
|
|
}
|
||
|
|
},
|
||
|
|
"number_of_shards": 1,
|
||
|
|
"number_of_replicas": 0
|
||
|
|
}
|
||
|
|
},
|
||
|
|
"mappings": {
|
||
|
|
"properties": {
|
||
|
|
"id": { "type": "keyword" },
|
||
|
|
"title": {
|
||
|
|
"type": "text",
|
||
|
|
"analyzer": "veza_text",
|
||
|
|
"fields": {
|
||
|
|
"keyword": { "type": "keyword" },
|
||
|
|
"fuzzy": {
|
||
|
|
"type": "text",
|
||
|
|
"analyzer": "veza_text"
|
||
|
|
}
|
||
|
|
}
|
||
|
|
},
|
||
|
|
"artist": {
|
||
|
|
"type": "text",
|
||
|
|
"analyzer": "veza_text",
|
||
|
|
"fields": {
|
||
|
|
"keyword": { "type": "keyword" }
|
||
|
|
}
|
||
|
|
},
|
||
|
|
"description": {
|
||
|
|
"type": "text",
|
||
|
|
"analyzer": "veza_text"
|
||
|
|
},
|
||
|
|
"album": {
|
||
|
|
"type": "text",
|
||
|
|
"analyzer": "veza_text",
|
||
|
|
"fields": { "keyword": { "type": "keyword" } }
|
||
|
|
},
|
||
|
|
"genre": { "type": "keyword" },
|
||
|
|
"tags": { "type": "keyword" },
|
||
|
|
"created_at": { "type": "date" },
|
||
|
|
"cover_art_path": { "type": "keyword", "index": false },
|
||
|
|
"stream_manifest_url": { "type": "keyword", "index": false },
|
||
|
|
"file_path": { "type": "keyword", "index": false }
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}`
|
||
|
|
|
||
|
|
// User mapping: username, display_name, bio (F362)
|
||
|
|
const usersMapping = `{
|
||
|
|
"settings": {
|
||
|
|
"analysis": {
|
||
|
|
"analyzer": {
|
||
|
|
"veza_text": {
|
||
|
|
"type": "custom",
|
||
|
|
"tokenizer": "standard",
|
||
|
|
"filter": ["lowercase", "asciifolding"]
|
||
|
|
}
|
||
|
|
},
|
||
|
|
"number_of_shards": 1,
|
||
|
|
"number_of_replicas": 0
|
||
|
|
}
|
||
|
|
},
|
||
|
|
"mappings": {
|
||
|
|
"properties": {
|
||
|
|
"id": { "type": "keyword" },
|
||
|
|
"username": {
|
||
|
|
"type": "text",
|
||
|
|
"analyzer": "veza_text",
|
||
|
|
"fields": { "keyword": { "type": "keyword" } }
|
||
|
|
},
|
||
|
|
"display_name": {
|
||
|
|
"type": "text",
|
||
|
|
"analyzer": "veza_text",
|
||
|
|
"fields": { "keyword": { "type": "keyword" } }
|
||
|
|
},
|
||
|
|
"bio": { "type": "text", "analyzer": "veza_text" },
|
||
|
|
"location": { "type": "keyword" },
|
||
|
|
"avatar": { "type": "keyword", "index": false },
|
||
|
|
"created_at": { "type": "date" }
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}`
|
||
|
|
|
||
|
|
// Playlist mapping (F363)
|
||
|
|
const playlistsMapping = `{
|
||
|
|
"settings": {
|
||
|
|
"analysis": {
|
||
|
|
"analyzer": {
|
||
|
|
"veza_text": {
|
||
|
|
"type": "custom",
|
||
|
|
"tokenizer": "standard",
|
||
|
|
"filter": ["lowercase", "asciifolding"]
|
||
|
|
}
|
||
|
|
},
|
||
|
|
"number_of_shards": 1,
|
||
|
|
"number_of_replicas": 0
|
||
|
|
}
|
||
|
|
},
|
||
|
|
"mappings": {
|
||
|
|
"properties": {
|
||
|
|
"id": { "type": "keyword" },
|
||
|
|
"name": {
|
||
|
|
"type": "text",
|
||
|
|
"analyzer": "veza_text",
|
||
|
|
"fields": { "keyword": { "type": "keyword" } }
|
||
|
|
},
|
||
|
|
"description": { "type": "text", "analyzer": "veza_text" },
|
||
|
|
"visibility": { "type": "keyword" },
|
||
|
|
"cover_url": { "type": "keyword", "index": false },
|
||
|
|
"created_at": { "type": "date" }
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}`
|
||
|
|
|