如何按嵌套对象整数字段排序

时间:2019-08-02 05:35:22

标签: django sorting elasticsearch elasticsearch-dsl

我正在尝试按价格对Elasticsearch文档进行排序。我有这个文件:

server.port: 5601
# Specifies the address to which the Kibana server will bind. IP addresses and host names are both valid values.
# The default is 'localhost', which usually means remote machines will not be able to connect.
# To allow connections from remote users, set this parameter to a non-loopback address.
server.host: 10.xx.xx.xx
# Enables you to specify a path to mount Kibana at if you are running behind a proxy.
# Use the `server.rewriteBasePath` setting to tell Kibana if it should remove the basePath
# from requests it receives, and to prevent a deprecation warning at startup.
# This setting cannot end in a slash.
#server.basePath: ""
# Specifies whether Kibana should rewrite requests that are prefixed with
# `server.basePath` or require that they are rewritten by your reverse proxy.
# This setting was effectively always `false` before Kibana 6.3 and will
# default to `true` starting in Kibana 7.0.
#server.rewriteBasePath: false
# The maximum payload size in bytes for incoming server requests.
#server.maxPayloadBytes: 1048576
# The Kibana server's name.  This is used for display purposes.
server.name: "ironman"
# The URLs of the Elasticsearch instances to use for all your queries.
elasticsearch.hosts: ["http://35.xxx.xx.xxx:9200/"]
# When this setting's value is true Kibana uses the hostname specified in the server.host
# setting. When the value of this setting is false, Kibana uses the hostname of the host
# that connects to this Kibana instance.
#elasticsearch.preserveHost: true
# Kibana uses an index in Elasticsearch to store saved searches, visualizations and
# dashboards. Kibana creates a new index if the index doesn't already exist.
#kibana.index: ".kibana"
# The default application to load.
#kibana.defaultAppId: "home"

因此,我在Elasticsearch中有55000个产品,我必须按其报价对它们进行排序。所以我做了:
        class OfferDocument(InnerDoc): partner_price = Float() class ProductDocument(DocType): view_count = Integer() offers = Nested(OfferDocument)
当我这样做:
        s = ProductDocument.search().query(some_query).sort({'offers.partner_price':{'order':'asc', 'mode': 'min'}})
排序正确。但是,它与嵌套对象提供及其字段partner_price的排序不正确。我怎么了?

0 个答案:

没有答案