jho*_*101 2 elasticsearch elasticsearch-query
如果我向以下查询添加折叠子句,则会出现错误
“折叠类型未知
aircraft_type_search,仅接受关键字和数字”
被返回。
{
"query": {
"bool": {
"must": {
"bool": {
"must": [
{
"match": {
"aircraft_type_search": {
"query": "piper"
}
}
}
]
}
},
"filter": {
"bool": {
"must": {
"term": {
"display_picture": "yes"
}
}
}
}
}
},
"collapse": {
"field": "aircraft_type_search"
}
}
Run Code Online (Sandbox Code Playgroud)
我也尝试过'aircraft_id'作为折叠字段,因为它是一个整数:
'aircraft_id' => [ 'type' => 'integer', "null_value" => "-1", "ignore_malformed" => 'true', 'include_in_all' => 'false', 'index' => 'not_analyzed' ]
Run Code Online (Sandbox Code Playgroud)
但这导致了错误。
AWS Elastic Search 服务上的 ES7.1 通过 elasticsearch php sdk 运行。
如果我删除折叠子句,查询就可以正常工作。
关于为什么这不起作用的任何想法?
小智 9
这是因为正如错误所述,折叠仅适用于关键字和数字字段。
你有两个解决方案:
PUT my-index
{
"mappings": {
"properties": {
"aircraft_type_search" : {
"type": "keyword"
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
"collapse": {
"field": "aircraft_type_search.keyword"
}
Run Code Online (Sandbox Code Playgroud)
为了选择最佳解决方案,您必须了解什么是文本或关键字类型。如果你不想加深主题,最简单的方法是解决方案2。
| 归档时间: |
|
| 查看次数: |
4009 次 |
| 最近记录: |