Custom Types For Music Collection For Best Practices

I am new to Elasticsearch(using v 6.3). I am creating a db for my mp3's.

After reading https://www.elastic.co/guide/en/elasticsearch/reference/6.x/removal-of-types.html, I am trying to create a similar mapping for the best results so:

  1. Data is more likely to be dense and so benefit from compression techniques used in Lucene.
  2. The term statistics used for scoring in full text search are more likely to be accurate because all documents in the same index represent a single entity.

Here are the mappings:

"mappings": {
  "_doc": {
    "properties": {
      "type": { "type": "keyword" },
      "title": { "type": "text" }, 
      "artist": { "type": "text" },
      "genre": { "type": "text" },
      "track": { "type": "text" },
      "date": { "type": "date" },
      "filepath": { "type": "text" },
      "playlist": { "type": "text" },
      "liked": { "type": "boolean" },
      "deleted": { "type": "boolean" }
    }
} 

Later I might do queries based on song title, band , deleted, liked, genre, or play list.

When I insert a song, will I be doing each category(that I would query) in a separate http request with it's type?

For instance.... for song 'take on me' by a-ha, would I do the following?

And what is significance of the url /fragments band-ah-ha and /song-take-on-me?

PUT song/_doc/band-ah-ha
{
  "type": "band",
  "band": "ah-ha"
}

PUT song/_doc/song-take-on-me
{
  "type": "song",
   "title": "take on me",
   "band": "ah-ha"
}

You can do that or do:

PUT band/_doc/ah-ha
{
  "band": "ah-ha"
}

PUT song/_doc/take-on-me
{
   "title": "take on me",
   "band": "ah-ha"
}
1 Like

Thank you.

Since I read where having separate indexes would make more shards, I think I would like to do it the other way in my original post.

From https://www.elastic.co/guide/en/elasticsearch/reference/6.x/removal-of-types.html can you please tell me the significance of using last hash url parameter user-kimchy in twitter/_doc/user-kimchy?

From:

PUT twitter/_doc/user-kimchy
{
  "type": "user", 
  "name": "Shay Banon",
  "user_name": "kimchy",
  "email": "shay@kimchy.com"
}

This is the document id.

If you don't care about the id, you can let elasticsearch generate it for you:

POST twitter/_doc
{
  "type": "user", 
  "name": "Shay Banon",
  "user_name": "kimchy",
  "email": "shay@kimchy.com"
}

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.