def setUp(self): super(TestRelatedContent, self).setUp() es = related.get_connection() related.delete(es) related.create(es) index = related.get_index() es.health(index=index, wait_for_status="yellow", wait_for_relocating_shards=0, timeout="5m") # wait for all
def setUp(self): super(TestRelatedContent, self).setUp() es = related.get_connection() related.delete(es) related.create(es) index = related.get_index() es.health( index=index, wait_for_status='yellow', wait_for_relocating_shards=0, # wait for all timeout='5m')
def related_content(request): es = related.get_connection() index = related.get_index() if request.method == 'POST': form = forms.ReindexRelatedContentForm(request.POST) if form.is_valid(): if form.cleaned_data['delete_and_recreate']: try: related.delete(es) except pyelasticsearch.ElasticHttpNotFoundError: pass related.create(es) form.cleaned_data['all'] = True since = None if form.cleaned_data['since']: since = datetime.timedelta( minutes=form.cleaned_data['since'] ) related.index( all=form.cleaned_data['all'], since=since ) messages.success( request, 'Re-indexing issued.' ) return redirect('manage:related_content') else: initial = { 'since': 30, } form = forms.ReindexRelatedContentForm(initial=initial) query = { 'query': { 'match_all': {} } } try: count = es.count(query, index=index)['count'] except pyelasticsearch.ElasticHttpNotFoundError: count = 'no' context = { 'form': form, 'count_indexed': count, 'count_events': Event.objects.scheduled_or_processing().count(), 'index_name': index, } return render(request, 'manage/related_content.html', context)