Revision 77c65646 core/management/commands/index_tickets.py

b/core/management/commands/index_tickets.py
2 2
# vim: tabstop=4:shiftwidth=4:softtabstop=4:expandtab
3 3

  
4 4
from django.core.management.base import BaseCommand, CommandError
5
from core.models import * 
6 5
from django.conf import settings
7 6
from pyelasticsearch import ElasticSearch
8 7
from core.jiramodels import *
......
22 21
        # Take care of mappings
23 22
        if settings.CUSTOMFIELD_MAPPING:
24 23
            for mapping in settings.CUSTOMFIELD_MAPPING:
25
                print mapping
26
                es.put_mapping("%s" %settings.ELASTIC_SEARCH_INDEX, "issue", {"issue":{"properties":mapping}})
24
                try:
25
                    es.put_mapping("%s" %settings.ELASTIC_SEARCH_INDEX, "issue", {"issue":{"properties":mapping}})
26
                except Exception as e:
27
                    print e
27 28
        for t in tickets:
28
            #print "Parsing %s, %s" %(t.id, t.key)
29
            es.index("%s" %settings.ELASTIC_SEARCH_INDEX, "issue", t.__dict__, id=int(t.id), overwrite_existing=True)
29
            print "Parsing %s, %s" %(t.id, t.key)
30
            try:
31
                es.index("%s" %settings.ELASTIC_SEARCH_INDEX, "issue", t.__dict__, id=int(t.id), overwrite_existing=True)
32
            except Exception as e:
33
                    print e
30 34
            #print "Indexed"
31 35
        es.refresh("%s" %settings.ELASTIC_SEARCH_INDEX)
32 36
        print "Done"

Also available in: Unified diff