Django-Haystack-Elasticsearch" text"字段是空的

时间:2014-03-11 19:00:57

标签: django django-haystack

运行index_update命令后,我收到以下消息:

索引452法定人数感觉   索引1 - 452 of 452(by 4672)

这很好,因为数据库中有452行数据。但是,当我检查数据字段时,所有数据字段都包含除" text"之外的数据。领域。因此,我无法使用Haystack搜索数据库。

什么会导致"文字'字段是空的?那么,数据库中的文本字段会导致这种情况吗?任何帮助将不胜感激!

以下是我的一些代码:

search-indexes.py

from bacterial.models import Quorum_Sensing
from haystack import indexes

class Quorum_SensingIndex(indexes.SearchIndex, indexes.Indexable):
    text = indexes.CharField(document=True, use_template=True, template_name='quorum_sensing_text.txt')
    Category_Inducer_Molecule = indexes.CharField(model_attr='Category_Inducer_Molecule', faceted=True)
    Inducer_Name_Synonym_Abbreviation = indexes.CharField(model_attr='Inducer_Name_Synonym_Abbreviation', faceted=True)
    Amino_Acid_Sequence_Inducer = indexes.CharField(model_attr='Amino_Acid_Sequence_Inducer', faceted=True)
    Organism_Involved = indexes.CharField(model_attr='Organism_Involved', faceted=True)
    Target_Protein = indexes.CharField(model_attr='Target_Protein', faceted=True)
    Broad_Functional_Category_Target_Molecule = indexes.CharField(model_attr='Broad_Functional_Category_Target_Molecule',faceted=True)

    def get_model(self):
        return Quorum_Sensing

    def index_queryset(self, using=None):
        return self.get_model().objects.all()

models.py

class Quorum_Sensing(models.Model):
    IUAPAC_NAME = models.CharField(max_length=400)
    Inducer_Molecule = models.CharField(max_length=100)
    Category_Inducer_Molecule = models.CharField(max_length=40)
    Inducer_Name_Synonym_Abbreviation = models.TextField()
    Chemical_Nature_Inducer_Molecule = models.CharField(max_length=40)
    Natural_Synthetic = models.CharField(max_length=120)
    Pubchem_Link_Inducer_Molecules = models.URLField()
    Mass_Inducer_Molecule = models.CharField(max_length=50)
    Number_Amino_Acids_In_Inducer_Molecule = models.CharField(max_length=60)
    IUPAC_Chemical_ID = models.CharField(max_length=60)
    QuorumPep_Link = models.URLField()
    Amino_Acid_Sequence_Inducer = models.CharField (max_length=300)
    SMILES = models.CharField(max_length=250)
    Organism_Involved = models.CharField (max_length=200)
    Strain1 = models.CharField(max_length=120)
    Strain2 = models.CharField(max_length=120)
    Strain3 = models.CharField(max_length=120)
    Strain4 = models.CharField(max_length=120)
    Strain5 = models.CharField(max_length=120)
    Taxonomy_Link = models.URLField()
    Pathogenic_Or_Not = models.CharField(max_length=120)
    Host = models.CharField(max_length=120)
    Target_Protein = models.CharField (max_length=160)
    Target_Protein_Length = models.CharField (max_length=40)
    Gene_Name = models.CharField(max_length=60)
    Broad_Functional_Category_Target_Molecule = models.CharField(max_length=300)
    GI = models.CharField(max_length=30)
    NCBI_Link_Target_Molecule = models.URLField(max_length=400)
    Mode_Of_Action = models.TextField()
    UNIPROT_Link_Target_Molecule = models.URLField()
    EMBL_Link_Target_Molecule = models.URLField()
    Related_Citations = models.URLField(max_length=400)
    Annotator = models.EmailField()

quorum_sensing_text.txt

{{ object.text }}
{{ object.Inducer_Name_Synonym_Abbreviation }}
{{ object.Category_Inducer_Molecule }}
{{ object.Amino_Acid_Sequence_Inducer }}
{{ object.Organism_Involved }}
{{ object.Target_Protein }}
{{ object.Broad_Functional_Category_Target_Molecule }}

0 个答案:

没有答案