Exemple #1
0
 def delete_singer(cls, singer_id):
     singer = Singer().get(singer_id, links=True)
     
     if singer is None:
         raise NotFoundException()
     
     # remove the singer from storage first
     singer.remove()
     
     # then remove the singer and re-index any related objects
     SingerIndex.delete_by_id(singer.id)
Exemple #2
0
 def create_singer(cls, singer_json, versions):
     if singer_json is None:
         return None
     
     # create the singer object and save it to the store
     singer = Singer({"singer" : singer_json})
     if versions is not None:
         singer.versions = versions
     singer.save()
     
     # call the indexing process, and index this object and all
     # related ones
     SingerIndex.by_id(singer.id, cascade=True)
     
     return singer
Exemple #3
0
 def update_singer(cls, singer_id, singer_json=None, versions=None):
     # retrieve and update the singer object in the desired way
     singer = Singer().get(singer_id, links=True)
     
     if singer is None:
         raise NotFoundException()
     
     if singer_json is not None:
         singer.patch_singer(singer_json, replace_all=True, keep_id=True)
     if versions is not None:
         singer.versions = versions
     singer.save()
     
     # call the indexing process, and index this object and all related ones
     SingerIndex.by_id(singer.id, cascade=True)
     
     return singer
Exemple #4
0
 def get_singer(cls, singer_id):
     singer = SingerIndex.pull(singer_id)
     if singer is None:
         raise NotFoundException()
     return singer.raw
# connection object to use for the save operations
conn = esprit.raw.Connection(host=settings.ELASTIC_SEARCH_HOST, index=settings.ELASTIC_SEARCH_DB)

# index all the songs
#####################

for sid in song_ids:
    song = Song().get(sid, links=True, host=settings.ELASTIC_SEARCH_HOST, index=settings.ELASTIC_SEARCH_DB)
    si = SongIndex.from_song(song)
    si.save(conn=conn)

# index all the singers
#######################

for sid in singer_ids:
    singer = Singer().get(sid, links=True, host=settings.ELASTIC_SEARCH_HOST, index=settings.ELASTIC_SEARCH_DB)
    si = SingerIndex.from_singer(singer)
    si.save(conn=conn)

# index all the versions
########################

for vid in version_ids:
    version = Version().get(vid, links=True, host=settings.ELASTIC_SEARCH_HOST, index=settings.ELASTIC_SEARCH_DB)
    vi = VersionIndex.from_version(version)
    vi.save(conn=conn)