def inset_one(event): """ insert event to solr index """ si = sunburnt.SolrInterface(settings.SOLR_ADDRESS) doc = { 'id': unicode(event.id), 'event_name_t': replace_illegal(event.title), 'event_name_t_ru': replace_illegal(event.title), 'address_t': replace_illegal(event.address), 'address_t_ru': replace_illegal(event.address), 'any_t_ru': replace_illegal(' '.join((event.title, event.address))) } si.add(doc) si.commit()
def insert(request): """ insert to solr index all events """ si = sunburnt.SolrInterface(settings.SOLR_ADDRESS) events_list = Event.objects.all() for event in events_list: doc = { 'id': unicode(event.id), 'event_name_t': replace_illegal(event.title), 'event_name_t_ru': replace_illegal(event.title), 'address_t': replace_illegal(event.address), 'address_t_ru': replace_illegal(event.address), 'any_t_ru': replace_illegal(' '.join((event.title, event.address))) } si.add(doc) si.commit() return HttpResponse(u'Ok')