ES 按照字段排序,忽略没有mapping的field
2019-06-13 本文已影响0人
良人与我
Ignoring Unmapped Fieldsedit
By default, the search request will fail if there is no mapping associated with a field. The unmapped_type option allows you to ignore fields that have no mapping and not sort by them. The value of this parameter is used to determine what sort values to emit. Here is an example of how it can be used:
GET /_search
{
"sort" : [
{ "price" : {"unmapped_type" : "long"} }
],
"query" : {
"term" : { "product" : "chocolate" }
}
}
pringboot 中
SearchQuery searchQuery = new NativeSearchQueryBuilder()
.withSort(SortBuilders.fieldSort("price").unmappedType("keyword").order(SortOrder.DESC))