Example #1
0
    def searchEntities(self, 
                       query, 
                       coords       = None, 
                       full         = True, 
                       local        = False, 
                       category     = None, 
                       subcategory  = None, 
                       offset       = 0, 
                       limit        = 10):
        results = []
        
        kinds, types = _convertCategorySubcategory(category, subcategory)
        
        try:
            if coords.lat is not None and coords.lng is not None:
                coords = (coords.lat, coords.lng)
            else:
                coords = None
        except Exception as e:
            logs.warning("Exception (%s) - setting coords to None" % e)
            coords = None
        
        search  = self.search(query, 
                              coords    = coords, 
                              full      = full, 
                              local     = local, 
                              offset    = offset, 
                              limit     = limit, 
                              kinds     = kinds,
                              types     = types)
        
        for item in search:
            source = item[1].target.source
            
            if source not in self._sources_map:
                source = 'stamped'

            entity = EntityProxyContainer().addProxy(item[1].target).buildEntity()

            # Hack to make sure entity_id is set (since it's not a part of a group)
            if source == 'stamped':
                entity.entity_id = item[1].target.key
            
            results.append(entity)
        
        return Entity.fast_id_dedupe(results)