2013-05-10 47 views
0

我使用的是Ubuntu 13和Django 1.4.5,我已經安裝了solr,tomcat6,(sudo apt-get install solr-tomcat)djangohaystack等,他們似乎工作正常。但我無法做出索引。django乾草堆索引什麼都沒有

search_indexes.py

from haystack import indexes, site 
from firms_api.models import Company 

class CompanyNameIndex(indexes.SearchIndex, indexes.Indexable): 
    text = indexes.CharField(document=True, use_template=True) 
    company_name = indexes.CharField(model_attr='company_name') 

    def get_model(self): 
     return Company 

     def __unicode__(self): 
      return self.Company.company_name 

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

site.register(Company, CompanyNameIndex) 

設置文件:

HAYSTACK_SITECONF = 'api' 
HAYSTACK_SEARCH_ENGINE = 'solr' 
HAYSTACK_WHOOSH_PATH = os.path.join(PROJECT_ROOT, 'djangobb_index') 
HAYSTACK_SOLR_URL = "http://solrserver.com/solr" 

比我:

python manage.py build_solr_schema -f schema.xml 
sudo mv schema.xml /etc/solr/conf/schema.xml 
sudo /etc/init.d/tomcat6 restart 
* Stopping Tomcat servlet engine tomcat6                        [ OK ] 
* Starting Tomcat servlet engine tomcat6                        [ OK ] 

python manage.py rebuild_index 
WARNING: This will irreparably remove EVERYTHING from your search index. 
Your choices after this are to restore from backups or rebuild via the `rebuild_index` command. 
Are you sure you wish to continue? [y/N] y 

Removing all documents from your index because you said so. 
All documents removed. 

python manage.py haystack_info 
Loaded URLconf to initialize SearchSite... 
Main site registered 0 index(es). 

當我試圖做出Solr的搜索我得到這個錯誤:

HTTP Status 400 - no field name specified in query and no defaultSearchField defined in schema.xml 

type Status report 

message no field name specified in query and no defaultSearchField defined in schema.xml 

description The request sent by the client was syntactically incorrect (no field name specified in query and no defaultSearchField defined in schema.xml). 

任何人有任何想法我犯了什麼錯誤?

感謝

回答

0

我已經安裝了草垛2.0.0測試版,現在的工作。