Devo cercare i valori della sottostringa in un campo modello. Ho un indice e un SearchQuerySet.Non funziona automaticamente con EdgeNgramField utilizzando pagliaio e motore Elasticsearch (Django)
Questa è la configurazione di Elasticsearch.
HAYSTACK_CONNECTIONS = {
'default': {
'ENGINE': 'haystack.backends.elasticsearch_backend.ElasticsearchSearchEngine',
'URL': 'http://127.0.0.1:9200/',
'INDEX_NAME': 'haystack',
},
}
Il mio indice.
class ElementIndex(indexes.SearchIndex, indexes.Indexable):
text = indexes.CharField(document=True, use_template=True)
#model fields
title_element = indexes.EdgeNgramField(model_attr='title')
clean_content = indexes.EdgeNgramField(model_attr='clean_content')
def get_model(self):
return Element
def index_queryset(self, using=None):
"""Used when the entire index for model is updated."""
return Element.objects.filter(updatetime__lte=datetime.datetime.now())
La mia ricerca personalizzata.
SearchQuerySet().filter(title_element=clean_value)
nel mio database ho un valore di "HolaMundoTest", e se provo a cercare per 'Hola' o 'Holam' trovo un risultato, ma se provo 'Mundo' o 'Mundo' o ' laMun 'non ci sono fiammiferi.
Cosa c'è di sbagliato? Non capisco.
fonte http://django-haystack.readthedocs.org/en/v2.1.0/autocomplete.html
sto usando:
- -django 1.5.1
- -django-pagliaio == 2.1.0
- -elasticsearch-0.90.5
- - pyelasticsearch == 0,6
Grazie per i vostri ans wers-