我们正在使用Django Rest Framework公开API以添加,编辑和检索有关用户及其技能的数据(具有级别)
我们拥有用户,技能和技能矩阵的模型(通过模型,我们需要为特定技能添加有关该用户技能水平的其他数据。)
class Freelancer(models.Model):
user = models.UUIDField (primary_key=True, default=uuid.uuid4, editable=False)
name = models.CharField(max_length=30)
contactNumber = models.BigIntegerField (default=None,blank=True, null=True)
emailAddress = models.EmailField (max_length=50, blank=False, null=True)
bachelorsDegree = models.CharField(max_length=50)
mastersDegree = models.CharField(max_length=50)
userCertificates = models.TextField(max_length=200)
IsActive = models.BooleanField (default=True)
UserPassword = models.CharField (max_length=50)
DeacivateDate = models.DateTimeField (blank=True, null=True)
Address = models.TextField(max_length=200)
Pincode = models.IntegerField()
class Skill(models.Model):
name = models.CharField(max_length=100)
skilltype = models.CharField(max_length=100,null=True)
userSkills = models.ManyToManyField(Freelancer,through='SkillMatrix')
class SkillMatrix(models.Model):
user = models.ForeignKey(Freelancer,on_delete=models.CASCADE)
skill = models.ForeignKey(Skill,on_delete=models.CASCADE)
level = models.CharField(max_length=100,null=True)
现在我的挑战如下:
我想找到最有效的方法来搜索具有特定技能的用户,并按最相关和最不相关的顺序返回。大约有10000名用户和大约300种技能。
因此,例如,如果所需的技能是[“python”,“html”,“css”,“postgres”]那么我应该能够返回UserID的列表,以便
User1>>技能Python,html,css,postgres all advanced
User2>>技能python html,css advanced,postgres intermediate
用户3>>技能python,html,css高级,没有postgres技能
请帮忙!