Ejemplo n.º 1
0
 def handle(self, *args, **options):
     logging.basicConfig(level=logging.INFO)
     percent = options['percent']
     delete = options['delete']
     if not 1 <= percent <= 100:
         raise CommandError('percent should be between 1 and 100')
     es_reindex_cmd(percent, delete)
Ejemplo n.º 2
0
    def setup_indexes(self):
        """(Re-)create ES indexes."""
        from search.es_utils import es_reindex_cmd

        # This removes the previous round of indexes and creates new
        # ones with mappings and all that.
        es_reindex_cmd(delete=True)
Ejemplo n.º 3
0
 def handle(self, *args, **options):
     percent = options['percent']
     delete = options['delete']
     models = options['models']
     if models:
         models = models.split(',')
     if not 1 <= percent <= 100:
         raise CommandError('percent should be between 1 and 100')
     es_reindex_cmd(percent, delete, models)
Ejemplo n.º 4
0
 def handle(self, *args, **options):
     percent = options['percent']
     delete = options['delete']
     models = options['models']
     if models:
         models = models.split(',')
     if not 1 <= percent <= 100:
         raise CommandError('percent should be between 1 and 100')
     es_reindex_cmd(percent, delete, models)
Ejemplo n.º 5
0
    def setup_indexes(self, empty=False, wait=True):
        """(Re-)create ES indexes."""
        from search.es_utils import es_reindex_cmd

        if empty:
            # Removes the index and creates a new one with
            # nothing in it (by abusing the percent argument).
            es_reindex_cmd(delete=True, percent=0)
        else:
            # Removes the previous round of indexes and creates new
            # ones with mappings and all that.
            es_reindex_cmd(delete=True)

        self.refresh(run_tasks=False)
Ejemplo n.º 6
0
    def setup_indexes(self, empty=False, wait=True):
        """(Re-)create ES indexes."""
        from search.es_utils import es_reindex_cmd

        if empty:
            # Removes the index and creates a new one with
            # nothing in it (by abusing the percent argument).
            es_reindex_cmd(delete=True, percent=0)
        else:
            # Removes the previous round of indexes and creates new
            # ones with mappings and all that.
            es_reindex_cmd(delete=True)

        self.refresh(run_tasks=False)
Ejemplo n.º 7
0
    def handle(self, *args, **options):
        percent = options["percent"]
        delete = options["delete"]
        models = options["models"]
        criticalmass = options["criticalmass"]
        if models:
            models = models.split(",")
        if not 1 <= percent <= 100:
            raise CommandError("percent should be between 1 and 100")
        if percent < 100 and criticalmass:
            raise CommandError("you can't specify criticalmass and percent")
        if models and criticalmass:
            raise CommandError("you can't specify criticalmass and models")

        es_reindex_cmd(percent, delete, models, criticalmass, FakeLogger(self.stdout))
Ejemplo n.º 8
0
    def handle(self, *args, **options):
        percent = options['percent']
        delete = options['delete']
        models = options['models']
        criticalmass = options['criticalmass']
        if models:
            models = models.split(',')
        if not 1 <= percent <= 100:
            raise CommandError('percent should be between 1 and 100')
        if percent < 100 and criticalmass:
            raise CommandError('you can\'t specify criticalmass and percent')
        if models and criticalmass:
            raise CommandError('you can\'t specify criticalmass and models')

        es_reindex_cmd(percent, delete, models, criticalmass,
                       FakeLogger(self.stdout))
Ejemplo n.º 9
0
    def handle(self, *args, **options):
        percent = options['percent']
        delete = options['delete']
        models = options['models']
        criticalmass = options['criticalmass']
        if models:
            models = models.split(',')
        if not 1 <= percent <= 100:
            raise CommandError('percent should be between 1 and 100')
        if percent < 100 and criticalmass:
            raise CommandError('you can\'t specify criticalmass and percent')
        if models and criticalmass:
            raise CommandError('you can\'t specify criticalmass and models')

        es_reindex_cmd(percent, delete, models, criticalmass,
                       FakeLogger(self.stdout))
Ejemplo n.º 10
0
    def setup_indexes(self):
        """(Re-)create ES indexes."""
        from search.es_utils import es_reindex_cmd

        # This removes the previous round of indexes and creates new
        # ones with mappings and all that.
        es_reindex_cmd(delete=True)

        # TODO: This is kind of bad.  If setup_indexes gets called in
        # a setUp and that setUp at some point throws an exception, we
        # could end up in a situation where setUp throws an exception,
        # so tearDown doesn't get called and we never set
        # ES_LIVE_INDEXING to False and thus ES_LIVE_INDEXING is True
        # for a bunch of tests it shouldn't be true for.
        #
        # For settings like this, it's better to mock it in the class
        # because the mock will set it back regardless of whether the
        # test fails.
        settings.ES_LIVE_INDEXING = True
Ejemplo n.º 11
0
    def setup_indexes(self):
        """(Re-)create ES indexes."""
        from search.es_utils import es_reindex_cmd

        if getattr(settings, 'ES_HOSTS', None) is None:
            raise SkipTest

        # TODO: Don't bother scanning through model objects and indexing any
        # that exist. None of our ES tests use any fixtures, so incremental
        # indexing will suffice for them.
        es_reindex_cmd()

        # TODO: This is kind of bad.  If setup_indexes gets called in
        # a setUp and that setUp at some point throws an exception, we
        # could end up in a situation where setUp throws an exception,
        # so tearDown doesn't get called and we never set
        # ES_LIVE_INDEXING to False and thus ES_LIVE_INDEXING is True
        # for a bunch of tests it shouldn't be true for.
        #
        # For settings like this, it's better to mock it in the class
        # because the mock will set it back regardless of whether the
        # test fails.
        settings.ES_LIVE_INDEXING = True
Ejemplo n.º 12
0
 def reindex_and_refresh(self):
     """Reindexes anything in the db"""
     from search.es_utils import es_reindex_cmd
     es_reindex_cmd()
     self.refresh(run_tasks=False)