1

我用弹性搜索实现了轮胎。在本地,我的项目运行良好,搜索索引也没有问题。但是当我将我的应用程序部署到我的服务器时,我收到了以下错误消息:

Tire::Search::SearchRequestFailed (500 : {"error":"SearchPhaseExecutionException[未能执行阶段 [query_fetch],完全失败;shardFailures {[hDTlT_K_Sl6P5regwKNJyg][articles] [0]: QueryPhaseExecutionException[[articles][0]: query[ConstantScore(NotDeleted(cache(_type:article)))],from[0],size[25],sort[!]: 查询失败[无法执行主查询]]; 嵌套: IOException[无法排序对于每个文档具有多个值或每个字段具有多个标记的字符串类型]; }]","status":500}):

我相信我的文章存储在我的索引中,因为创建它们时我没有收到任何错误。我还尝试使用以下方法手动运行相同的查询:

curl -XPOST 'http://localhost:9200/articles/article/_search' -d '{ 
    "sort": [ 
        { 
            "supplier_code": "desc" 
        } 
    ] 
}'

我得到了几乎相同的回应:

{"error":"SearchPhaseExecutionException[未能执行阶段 [query_fetch],完全失败;shardFailures {[hDTlT_K_Sl6P5regwKNJyg][articles][0]:QueryPhaseExecutionException[[articles][0]:query[ConstantScore(NotDeleted(cache(_type: article)))],from[0],size[10],sort[!]: Query Failed [Failed to execute main query]]; 嵌套: IOException[Can't sort on string types with more than one value per doc , 或每个字段多个标记]; }]","status":500}

那么有人可以指出我正确的方向吗?我复制了我在本地机器上使用的确切 sam 配置。太奇怪了,它在服务器上不起作用。

我在这里想念什么?

非常感谢提前

编辑:

我发现我正在尝试执行的排序导致了这个问题。这也与我的文章对象到弹性搜索的映射有关。

我试图排序的领域的东西放在 not_analyzed 我是对的吗?如果我只映射一个字段,是否需要显式映射我的所有字段?

4

1 回答 1

2

This is the actual issue: Can't sort on string types with more than one value per doc, or more than one token per field. It means one of two things: either you have multiple supplier_code fields per document or the field supplier_code is analyzed by an analyzer the produces multiple tokens (default analyzer would do that for some strings). Elasticsearch can only sort on fields that contains no more than one value per record. So, if you have multiple fields, you need to come up with another sort key or if you have a single field, you need to make it not_analyzed, or use some other analyzer that doesn't produce multiple tokens.

于 2012-09-06T21:03:27.947 回答