doskmc7870 2016-06-27 14:01
浏览 104

如何应用高斯函数进行Elasticsearch范围查询?

How would I construct an ElasticSearch query to satisfy the following:

Price must be between 100,000 & 200,000, but also show results outside of this range, but with decreasing relevance if above 200k or below 100k.

So far I have the following but it doesn't seem to be doing what I want (omitted the wrapping query for brevity):

"function_score": {
        "query": {
          "range": {
            "price_amount": {
              "gte": 100000,
              "lte": 200000
            }
          }
        },
        "functions": [
          {
            "gauss": {
              "price_amount": {
                "origin": "50000",
                "offset": "50000",
                "scale": "10000"
              }
            }
          }
        ]
      }

Update:

Had another look and I think setting the function to the following, without the range query would do the trick, wouldn't it?

"function_score": {
        "functions": [
          {
            "gauss": {
              "price_amount": {
                "origin": "150000",
                "offset": "50000",
                "scale": "10000"
              }
            }
          }
        ]
      }

Many thanks! Lee

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 微信会员卡接入微信支付商户号收款
    • ¥15 如何获取烟草零售终端数据
    • ¥15 数学建模招标中位数问题
    • ¥15 phython路径名过长报错 不知道什么问题
    • ¥15 深度学习中模型转换该怎么实现
    • ¥15 HLs设计手写数字识别程序编译通不过
    • ¥15 Stata外部命令安装问题求帮助!
    • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
    • ¥15 TYPCE母转母,插入认方向
    • ¥15 如何用python向钉钉机器人发送可以放大的图片?