Beispiel #1
0
def pushRecordToSearchIndex(mapObj, dbsession, logger, georefObj=None):
    """ Push the metadata for a given mapObj to the search index (actual ElasticSearch).
    
    :type georeference.models.vkdb.map.Map: mapObj
    :type sqlalchemy.orm.session.Session: dbsession
    :type logging.Logger: logger
    :type georefObj: georeference.models.vkdb.georeferenzierungsprozess.Georeferenzierungsprozess|None
    :return: str RecordId of the ElasticSearch record
    """
    datarecord = createSearchRecord(mapObj, dbsession, logger, georefObj)
    return pushRecordToEs(datarecord, ELASTICSEARCH_INDEX, logger)
Beispiel #2
0
def pushRecordToSearchIndex(mapObj, dbsession, logger, georefObj=None):
    """ Push the metadata for a given mapObj to the search index (actual ElasticSearch).
    
    :type georeference.models.vkdb.map.Map: mapObj
    :type sqlalchemy.orm.session.Session: dbsession
    :type logging.Logger: logger
    :type georefObj: georeference.models.vkdb.georeferenzierungsprozess.Georeferenzierungsprozess|None
    :return: str RecordId of the ElasticSearch record
    """
    datarecord = createSearchRecord(mapObj, dbsession, logger, georefObj)
    return pushRecordToEs(datarecord, ELASTICSEARCH_INDEX, logger)
    def testPushRecordToEs(self):
        mapObj = Map.by_id(10000023, self.dbsession)
        datarecord = createSearchRecord(mapObj, self.dbsession, self.logger)
        key = pushRecordToEs(datarecord, ELASTICSEARCH_INDEX, self.logger)

        print '====================='
        print 'Test if testPushRecordToEs ...'
        print 'Response: %s'%key
        print '====================='
        
        # check if the record was insert correctly
        response = getRecordFromEsById(key, ELASTICSEARCH_INDEX)
        self.assertEqual(response['found'], True, 'Could not find expected record')
        self.assertEqual(response['_id'], key, 'Key is not like expected')

        # clear up 
        response = deleteRecordFromEsById(key, ELASTICSEARCH_INDEX)
        if response['found'] is not True:
            raise Exception("Problems while trying to clean up elasticsearch test index")
    def testPushRecordToEs(self):
        mapObj = Map.by_id(10000023, self.dbsession)
        datarecord = createSearchRecord(mapObj, self.dbsession, self.logger)
        key = pushRecordToEs(datarecord, ELASTICSEARCH_INDEX, self.logger)

        print '====================='
        print 'Test if testPushRecordToEs ...'
        print 'Response: %s' % key
        print '====================='

        # check if the record was insert correctly
        response = getRecordFromEsById(key, ELASTICSEARCH_INDEX)
        self.assertEqual(response['found'], True,
                         'Could not find expected record')
        self.assertEqual(response['_id'], key, 'Key is not like expected')

        # clear up
        response = deleteRecordFromEsById(key, ELASTICSEARCH_INDEX)
        if response['found'] is not True:
            raise Exception(
                "Problems while trying to clean up elasticsearch test index")