haystack.Exceptions.SearchBackendError: ไม่พบฟิลด์ใน search_indexes ใด ๆ โปรดแก้ไขสิ่งนี้ก่อนที่จะพยายามค้นหา

ฉันกำลังพยายามใช้ Haystack ด้วย whoosh

ฉันได้รับข้อผิดพลาดนี้อยู่เรื่อยๆ แม้ว่าทุกอย่างดูเหมือนจะได้รับการกำหนดค่าได้ดีก็ตาม ฉันได้รับข้อผิดพลาด:

haystack.exceptions.SearchBackendError: No fields were found in any search_indexes. Please correct this before attempting to search.

...เมื่อฉันพยายามทำ ./manage.py rebuild_index

การกำหนดค่า:

HAYSTACK_SITECONF = 'myproject'
HAYSTACK_SEARCH_ENGINE = 'whoosh'
HAYSTACK_WHOOSH_PATH = cwd + '/whoosh/mysite_index'

มีการสร้างไดเร็กทอรี whoosh/mysite_index ในโฟลเดอร์รูทของโปรเจ็กต์ของฉันสำเร็จแล้ว

*search_sites.py*

import haystack
haystack.autodiscover()

*search_indexes.py*

from haystack.indexes import *
from haystack import site
from myproject.models import *

class ResearchersIndex(SearchIndex):
    text = CharField(document=True, use_template=True)
    name = CharFIeld(model_attr='name')

class SubjectIndex(SearchIndex):
    short_name = CharField(model_attr='short_name')
    name = CharField(model_attr='name')
    text = CharField(document=True, use_template=True)

class ResearchIndex(SearchIndex):
    text = CharField(document=True, use_template=True)
    abstract = TextField(model_attr='abstract')
    methodology = TextField(model_attr='methodology')
    year = IntegerField(model_attr='year')
    name = CharField(model_attr='name')


class Graph(SearchIndex):
    text = CharField(document=True, use_template=True)
    explanation = TextField(model_attr='explanation')
    type = CharField(model_attr='type')
    name = CharField(model_attr='name')

site.register(Researchers, ResearchersIndex)
site.register(Subject, SubjectIndex)
site.register(Research, ResearchIndex)
site.register(Graph, GraphIndex)

ขอบคุณ


person Tamara    schedule 07.03.2013    source แหล่งที่มา
comment
คุณทำเทมเพลตด้วยเหรอ?   -  person anacarolinats    schedule 07.03.2013
comment
ใช่ฉันทำ. ฉันมีไฟล์ .txt 4 ไฟล์ใน templates/search/indexes/myproject/ ที่สอดคล้องกับแต่ละคลาส นอกจากนี้ ฉันได้วางเทมเพลตสำหรับการค้นหา search.html จากบทช่วยสอนจากไซต์ และวางไว้ใต้ไดเร็กทอรี search/   -  person Tamara    schedule 07.03.2013
comment
คุณใช้หญ้าแห้งเวอร์ชันใดอยู่?   -  person anacarolinats    schedule 07.03.2013
comment
ฉันใช้เวอร์ชัน 1.2.7   -  person Tamara    schedule 07.03.2013
comment
HAYSTACK_SITECONF ของคุณคือสิ่งนั้นหรือคุณเปลี่ยนมาใส่ที่นี่   -  person anacarolinats    schedule 07.03.2013
comment
ไม่ นั่นคือสิ่งนั้น เพราะตอนที่ฉันมี myproject.search_sites มันบอกว่าไม่มีโมดูลชื่อ search_sites   -  person Tamara    schedule 07.03.2013
comment
ดังนั้นฉันคิดว่าปัญหาคือว่า search_sites ไม่ได้ถูกเรียก   -  person anacarolinats    schedule 08.03.2013
comment
ใช่แล้ว นั่นมัน! โปรดเขียนเป็นความคิดเห็นเพื่อที่ฉันจะได้เลือกเป็นคำตอบและขอบคุณมาก!   -  person Tamara    schedule 08.03.2013


คำตอบ (2)


ปัญหาอยู่ใน HAYSTACK_SITECONF ของคุณ จะต้องเป็นเส้นทางไปยังไฟล์ search_sites ของคุณ แก้ไขปัญหานี้และควรจะใช้งานได้

person anacarolinats    schedule 08.03.2013
comment
นี่ไม่ใช่คำตอบที่ถูกต้องอีกต่อไป: หากคุณพยายามใช้ HAYSTACK_SITECONF คุณจะได้รับข้อความว่าอย่าทำอย่างนั้น - person GreenAsJade; 11.12.2014
comment
นี่คือคำตอบสำหรับเวอร์ชันล่าสุดในเดือนเมษายน 2013 - person anacarolinats; 15.12.2014

ตรวจสอบให้แน่ใจว่า site_indexes.py ของคุณอยู่ในแอปที่คุณได้ลงทะเบียนใน INSTALLED_APPS ใน settings.py

person chaggy    schedule 31.05.2018