简体   繁体   English

Elasticsearch搜索数字字段

[英]Elasticsearch search on number field

I am new to elasticsearch. 我是Elasticsearch的新手。 Apologies if the question sounds very basic. 很抱歉,这个问题听起来很基本。 I am not able to get the answer directly from the documentations. 我无法直接从文档中获得答案。

Is there a way to do a search on number field with the returned docs score ranked based on how close the number is to the input filter. 有没有一种方法可以对数字字段进行搜索,并根据数字与输入过滤器的接近程度对返回的文档分数进行排名。 I mean, 我的意思是,

  • if I have 10 docs in the index, let's say book objects 如果索引中有10个文档,则说书对象
  • and the prices of them are 1 to 10 if I search for book price of 12$ 如果我搜索价格为12美元的书,它们的价格是1到10
  • I want to get the book of 10$ at the top and 9$ next and so forth... 我想让这本书的顶部10美元,接下来9美元,依此类推...

Is it possible with elasticsearch? elasticsearch有可能吗?

我建议您对弹性响应进行排序,如果您必须在elasticsearch中进行处理,则可以查看stript_score函数: https ://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-function- score-query.html#function-script-score

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM