Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/search/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Django 字母排序在haystack的弹性搜索中不起作用_Django_Search_<img Src="//i.stack.imgur.com/RUiNP.png" Height="16" Width="18" Alt="" Class="sponsor Tag Img">elasticsearch_Django Haystack - Fatal编程技术网 elasticsearch,django-haystack,Django,Search,elasticsearch,Django Haystack" /> elasticsearch,django-haystack,Django,Search,elasticsearch,Django Haystack" />

Django 字母排序在haystack的弹性搜索中不起作用

Django 字母排序在haystack的弹性搜索中不起作用,django,search,elasticsearch,django-haystack,Django,Search,elasticsearch,Django Haystack,我正在使用弹性搜索和haystack。我的问题是我不能按字母顺序排列结果。请注意,内容为希腊文。以下是我的索引 class ProfileIndex(indexes.SearchIndex, indexes.Indexable): text = indexes.EdgeNgramField(document=True, use_template=True) title = indexes.CharField(model_attr='title') sorted_title

我正在使用弹性搜索和haystack。我的问题是我不能按字母顺序排列结果。请注意,内容为希腊文。以下是我的索引

class ProfileIndex(indexes.SearchIndex, indexes.Indexable):
    text = indexes.EdgeNgramField(document=True, use_template=True)
    title = indexes.CharField(model_attr='title')
    sorted_title = indexes.CharField(model_attr='title', indexed=False, stored=True)
我专门为排序添加了排序标题

以下是索引设置:

    ELASTICSEARCH_INDEX_SETTINGS = {
    'settings': {
        "analysis": {
            "analyzer": {
                "ngram_analyzer": {
                    "type": "custom",
                    "tokenizer": "haystack_ngram_tokenizer",
                    "filter": [
                        "lowercase",
                        "greek_lowercase",
                        "greek_stem",
                        "english_stem",
                        "my_stop",
                        "haystack_ngram"
                    ]
                },
                "edgengram_analyzer": {
                    "type": "custom",
                    "tokenizer": "standard",
                    "filter": [
                        "lowercase",
                        "greek_lowercase",
                        "greek_stem",
                        "english_stem",
                        "my_stop",
                        "haystack_edgengram"
                    ]
                },
                "myanalyzer": {
                    "type": "custom",
                    "tokenizer": "standard",
                    "filter": [
                        "lowercase",
                        "greek_lowercase",
                        "greek_stem",
                        "english_stem",
                        "my_stop",
                        "my_edgengram",
                    ]
                },
            },
            "tokenizer": {
                "haystack_ngram_tokenizer": {
                    "type": "nGram",
                    "min_gram": 1,
                    "max_gram": 12,
                },
                "haystack_edgengram_tokenizer": {
                    "type": "edgeNGram",
                    "min_gram": 1,
                    "max_gram": 12,
                    "side": "front"
                }
            },
            "filter": {
                "haystack_ngram": {
                    "type": "nGram",
                    "min_gram": 1,
                    "max_gram": 12
                },
                "haystack_edgengram": {
                    "type": "edgeNGram",
                    "min_gram": 1,
                    "max_gram": 12
                },
                "my_edgengram": {
                    "type": "edgeNGram",
                    "min_gram": 1,
                    "max_gram": 10
                },
                "my_ngram": {
                    "type": "nGram",
                    "min_gram": 1,
                    "max_gram": 10
                },
                "greek_lowercase": {
                    "type": "lowercase",
                    "language": "greek"
                },
                "greek_stem": {
                    "type": "stemmer",
                    "name": "greek"
                },
                "english_stem": {
                    "type": "stemmer",
                    "name": "english"
                },
                "my_stop": {
                    "type": "stop",
                    "stopwords": ["_greek_", "_english_"]
                }
            }
        }
    }
}
任何帮助都将不胜感激


谢谢。

如果排序的标题仅用于排序,我认为您应该为其编制索引(排序时必须填写),而不应该对其进行分析。(或者,如果必须,您应该使用关键字分析器)。在分析的字段上进行排序和刻面可能会导致意外的结果,因为分析器创建的所有标记都被考虑在内。我不是elasticsearch/haystack专家,但我曾经遇到过类似的问题,我的自定义分析器设置没有被应用。最后,在本文的帮助下,我成功地切换到了“标准”分析器:如果这完全没有用,我很抱歉。@ptrck感谢您发布链接。是的,我已经按照文章中提到的配置,问题是我不能使用标准分析器,因为我还有其他要求。