Exemplo n.º 1
0
    def testImageRecordsOnlySolrIndexing(self):
        image_record = Record.objects.create()
        image_record2 = Record.objects.create()

        image_record.fieldvalue_set.create(
            field=self.dcrelation, refinement='IsPartOf', value='SET1')
        image_record2.fieldvalue_set.create(
            field=self.dcrelation, refinement='IsPartOf', value='SET1')

        identifiers = [image_record.id, image_record2.id]

        index = SolrIndex()
        work_to_images = index._preload_work_to_images(identifiers)
        self.assertEqual(2, len(work_to_images))
        self.assertEqual([image_record.id], work_to_images[image_record2.id])
        self.assertEqual([image_record2.id], work_to_images[image_record.id])

        image_to_works = index._preload_image_to_works(identifiers)
        self.assertEqual(0, len(image_to_works))
Exemplo n.º 2
0
    def testSolrIndexing(self):
        work_record = Record.objects.create()
        image_record = Record.objects.create()
        image_record2 = Record.objects.create()

        work_record.fieldvalue_set.create(field=self.dcid, value='SOLR')
        image_record.fieldvalue_set.create(
            field=self.dcrelation, refinement='IsPartOf', value='SOLR')
        image_record2.fieldvalue_set.create(
            field=self.dcrelation, refinement='IsPartOf', value='SOLR')

        identifiers = [work_record.id, image_record.id, image_record2.id]

        index = SolrIndex()
        work_to_images = index._preload_work_to_images(identifiers)
        self.assertEqual(3, len(work_to_images))
        w2i = work_to_images[work_record.id]
        self.assertTrue(image_record.id in w2i)
        self.assertTrue(image_record2.id in w2i)

        image_to_works = index._preload_image_to_works(identifiers)
        self.assertEqual(2, len(image_to_works))
        self.assertEqual([work_record.id], image_to_works[image_record.id])
        self.assertEqual([work_record.id], image_to_works[image_record2.id])
Exemplo n.º 3
0
 def handle(self, *commands, **options):
     if not commands:
         print self.help
     else:
         s = SolrIndex()
         for command in commands:
             if command == 'optimize':
                 s.optimize()
             elif command == 'index':
                 s.index(verbose=True)
             elif command == 'reindex':
                 s.index(verbose=True, all=True)
                 s.clear_missing(verbose=True)
             elif command == 'clean':
                 s.clear_missing(verbose=True)
             elif command == 'rebuild':
                 s.clear()
                 s.index(verbose=True, all=True)
             elif command == 'clear':
                 s.clear()
             else:
                 print "Invalid command %s" % command
def solr_index(data):
    logger.info("Starting solr index")
    count = SolrIndex().index()
    logger.info("solr index done, indexed %d records" % count)
Exemplo n.º 5
0
 def handle(self, *commands, **options):
     if not commands:
         print self.help
     else:
         s = SolrIndex()
         for command in commands:
             if command == 'optimize':
                 s.optimize()
             elif command == 'index':
                 s.index(verbose=True)
             elif command == 'reindex':
                 s.index(verbose=True, all=True)
                 s.clear_missing(verbose=True)
             elif command == 'clean':
                 s.clear_missing(verbose=True)
             elif command == 'rebuild':
                 s.clear()
                 s.index(verbose=True, all=True)
             elif command == 'clear':
                 s.clear()
             else:
                 print "Invalid command %s" % command
Exemplo n.º 6
0
    def handle(self, *args, **kwargs):
        if not args:
            print self.help
        else:
            collections = map(int, kwargs.get('collections') or list())

            s = SolrIndex()
            for command in args:
                if command == 'optimize':
                    s.optimize()
                elif command == 'index':
                    s.index(verbose=True)
                elif command == 'reindex':
                    s.index(verbose=True, all=True, collections=collections)
                    s.clear_missing(verbose=True)
                elif command == 'clean':
                    s.clear_missing(verbose=True)
                elif command == 'rebuild':
                    s.clear()
                    s.index(verbose=True, all=True, collections=collections)
                elif command == 'clear':
                    s.clear()
                else:
                    print "Invalid command %s" % command
Exemplo n.º 7
0
    def handle(self, *args, **kwargs):
        if not args:
            print self.help
        else:
            collections = map(int, kwargs.get('collections') or list())

            s = SolrIndex()
            for command in args:
                if command == 'optimize':
                    s.optimize()
                elif command == 'index':
                    s.index(verbose=True)
                elif command == 'reindex':
                    s.index(verbose=True, all=True, collections=collections)
                    s.clear_missing(verbose=True)
                elif command == 'clean':
                    s.clear_missing(verbose=True)
                elif command == 'rebuild':
                    s.clear()
                    s.index(verbose=True, all=True, collections=collections)
                elif command == 'clear':
                    s.clear()
                else:
                    print "Invalid command %s" % command