我正在使用Haystack 2.3.1并尝试找出多个索引。
我已经设置了弹性搜索核心并在HAYSTACK_CONNECTIONS中定义了每个核心 然后我在search_indexes.py中创建了三个SearchIndex。
当我运行命令manage.py rebuild_index时,我看到了这个警告。
感谢您提供的任何提示,如果我遗漏任何内容,请告知我们。
setting.py:
```
HAYSTACK_CONNECTIONS = {
'default': {
'ENGINE': 'haystack.backends.elasticsearch_backend.ElasticsearchSearchEngine',
'URL': 'http://127.0.0.1:9200/',
'INDEX_NAME': 'default',
'TIMEOUT': 60 * 5,
'INCLUDE_SPELLING': True,
'SILENTLY_FAIL': True,
'EXCLUDED_INDEXES': ['dmmactress.search_indexes.ActressInfoIndex'],
},
'autocomplete': {
'ENGINE': 'haystack.backends.elasticsearch_backend.ElasticsearchSearchEngine',
'URL': 'http://127.0.0.1:9200/',
'INDEX_NAME': 'autocomplete',
'TIMEOUT': 60 * 5,
'INCLUDE_SPELLING': True,
'SILENTLY_FAIL': True,
'EXCLUDED_INDEXES': ['dmmactress.search_indexes.EnActress'],
},
'autocomplete2': {
'ENGINE': 'haystack.backends.elasticsearch_backend.ElasticsearchSearchEngine',
'URL': 'http://127.0.0.1:9200/',
'INDEX_NAME': 'autocomplete2',
'TIMEOUT': 60 * 5,
'INCLUDE_SPELLING': True,
'SILENTLY_FAIL': True,
'EXCLUDED_INDEXES': ['dmmactress.search_indexes.EnMovielist'],
},
}
HAYSTACK_SIGNAL_PROCESSOR = 'haystack.signals.RealtimeSignalProcessor'
```
search_indexes.py
```
class ActressInfoIndex(indexes.SearchIndex, indexes.Indexable):
text = indexes.EdgeNgramField(document=True, use_template=True)
name = indexes.CharField(model_attr='name')
birth = indexes.CharField(model_attr='birth')
starsign = indexes.CharField(model_attr='starsign')
bloodtype = indexes.CharField(model_attr='bloodtype')
boobs = indexes.CharField(model_attr='boobs')
home = indexes.CharField(model_attr='home')
hobby = indexes.CharField(model_attr='hobby')
image_paths = indexes.CharField(model_attr='image_paths')
def get_model(self):
return ActressInfo
def index_queryset(self, using=None):
"""Used when the entire index for model is updated."""
return self.get_model().objects.all()
class EnActress(indexes.SearchIndex, indexes.Indexable):
text = indexes.EdgeNgramField(document=True, use_template=True)
name = indexes.CharField(model_attr='name')
image_paths = indexes.CharField(model_attr='image_paths')
def get_model(self):
return EnActress
def index_queryset(self, using=None):
"""Used when the entire index for model is updated."""
return self.get_model().objects.all()
class EnMovielist(indexes.SearchIndex, indexes.Indexable):
text = indexes.EdgeNgramField(document=True, use_template=True)
Content_ID = indexes.CharField(model_attr='Content_ID')
release_date = indexes.CharField(model_attr='release_date')
running_time = indexes.CharField(model_attr='running_time')
Actress = indexes.CharField(model_attr='Actress')
Series = indexes.CharField(model_attr='Series')
Studio = indexes.CharField(model_attr='Studio')
Director = indexes.CharField(model_attr='Director')
Label = indexes.CharField(model_attr='Label')
image_paths = indexes.CharField(model_attr='image_paths')
def get_model(self):
return EnMovielist
def index_queryset(self, using=None):
"""Used when the entire index for model is updated."""
return self.get_model().objects.all()
```
_text.txt
```
{{ object.name}}
{{ object.image_paths }}
{{ object.birth }}
{{ object.starsign }}
{{ object.bloodtype }}
{{ object.boobs }}
{{ object.home }}
{{ object.hobby }}
{{ object.EnMovielist.Content_ID }}
{{ object.EnMovielist.image_paths }}
{{ object.EnMovielist.release_date }}
{{ object.EnMovielist.running_time }}
{{ object.EnMovielist.Actress }}
{{ object.EnMovielist.Series }}
{{ object.EnMovielist.Studio }}
{{ object.EnMovielist.Director }}
{{ object.EnMovielist.Label }}
{{ object.EnActress.name}}
{{ object.EnActress.image_paths }}
```
运行后..
Indexing 9464 actress infos
GET /autocomplete/_mapping [status:404 request:0.001s]
Indexing 9464 actress infos
GET /autocomplete2/_mapping [status:404 request:0.003s]
答案 0 :(得分:0)
确保您使用的是哪个版本的elasticsearch
?如果您使用django-haystack
,则elasticsearch
应小于2.00。