J'ai un problème avec la méthode .sort()
. Par exemple, j'ai Index avec texte() Champ:elasticsearch-dsl-py Tri par champ Texte()
FILTER = token_filter(
'FILTER', 'edge_ngram', min_gram=3, max_gram=40)
ANALYZER = analyzer(
'ANALYZER', tokenizer='standard', type='custom', filter=[
'standard', 'lowercase', 'stop', 'asciifolding',FILTER])
class Article(DocType):
title = Text(analyzer=ANALYZER)
body = Text(analyzer='snowball')
tags = Keyword()
search = Article.search().sort('title')
search.execute()
lorsque je tente d'exécuter la requête de recherche avec sorte que je reçois une erreur:
elasticsearch.exceptions.RequestError: TransportError(400, 'search_phase_execution_exception', 'Fielddata is disabled on text fields by default. Set fielddata=true on [title] in order to load fielddata in memory by uninverting the inverted index. Note that this can however use significant memory.')
Comment puis-je trier par title
champ correctement dans ce cas sans réglage fieldata=true
?
que diriez-vous 'String()' champ? Puis-je trier sur un champ 'string'? – pkisztelinski
'String' est déprécié,' String (index = "not_analyzed") 'a été remplacé par' keyword' et toutes les autres instances de 'String' sont analogues à' text', donc les mêmes restrictions s'appliquent. –
Notez que vous n'avez pas à choisir, vous pouvez utiliser les deux types de champs ('text' et' keyword') en utilisant le paramètre 'fields' - https://www.elastic.co/guide/fr/elasticsearch/ reference/current/multi-fields.html –