关于postgresql:Flask-msearch python,在多对多表上添加msearch

Flask-msearch python , adding msearch on many to many table

我正在使用postgres数据库进行python,我有两个表有多对多的关系,第三个表保存了关系,我需要以一种它取出的方式对关系表应用flask-msearch。 在两个表中搜索并给出结果输出,我已在单个表上实现它在那里工作正常但不能在多对多关系中工作

这是我的模型正常工作

1
2
3
4
5
class JobpostJobpost(db.Model):
    __tablename__ = 'jobpost_jobpost'
    __searchable__ = ['company_name']  
    id = db.Column('job_id', Integer, primary_key=True)
    company_name = db.Column(String(255))

&安培; 要搜索我必须使用此查询

1
JobpostJobpost.query.msearch(query,fields=['company_name'])

它给出了准确的结果,但是当我将它用于多表时,它在这里给出错误我的模型代码为multitable

1
2
3
4
5
6
7
class TblDegreeSpecilizationRelation(db.Model):
    __tablename__ = 'tbl_degree_specilization_relation'
    __searchable__ = ['tbl_suggestion_degrees.name','tbl_suggestion_degrees.tags'] # ,'tbl_suggestion_degree_specilization.name' ,'tbl_suggestion_degree_specilization.tags'

    id = db.Column('id', Integer, nullable=False, primary_key=True)
    degree_id = db.Column('degree_id', ForeignKey(u'tbl_suggestion_degrees.id', ondelete=u'CASCADE'))
    specilization_id  = db.Column('specilization_id', ForeignKey(u'tbl_suggestion_degree_specilization.id', ondelete=u'CASCADE'))


我已经解决了这个问题,我正在使用tablename和.column名称我将其更改为,
模型

1
2
3
4
5
6
7
8
9
10
11
12
class TblDegreeSpecilizationRelation(db.Model):
__tablename__ = 'tbl_degree_specilization_relation'
__searchable__ = ['degree.name','degree.tags', 'specilization.name', 'specilization.tags'] # ,'tbl_suggestion_degree_specilization.name' ,'tbl_suggestion_degree_specilization.tags'

id = db.Column('id', Integer, nullable=False, primary_key=True)
degree_id = db.Column('degree_id', ForeignKey(u'tbl_suggestion_degrees.id', ondelete=u'CASCADE'))
specilization_id  = db.Column('specilization_id', ForeignKey(u'tbl_suggestion_degree_specilization.id', ondelete=u'CASCADE'))

degree = relationship(u'TblSuggestionDegrees',backref=db.backref(
        'post', uselist=False), uselist=False)
specilization = relationship(u'TblSuggestionDegreeSpecilization',backref=db.backref(
        'post', uselist=False), uselist=False)

现在工作正常