- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
Elasticsearch的索引仅包含post_id
和created_at
。
我想使用post_id
作为键来group_by。
如果按以下方式使用search ()
,则可以获取每个post_id
的分数。
res = elastic.search(index='play_post',
body={
"size": 0,
"query": {
"range": {
"created_at": {
"gte": start_date,
"lte": end_date
}
}
},
"aggs": {
"group_by_post_id": {
"terms": {
"field": "post_id"
}
}
}
},
request_timeout=300)
{u'hits': {u'hits': [], u'total': 2606639, u'max_score': 0.0}, u'_shards': {u'successful': 5, u'failed': 0, u'total': 5}, u'took': 318, u'aggregations': {u'group_by_post_id': {u'buckets': [{u'key': 29062, u'doc_count': 136}, {u'key': 2499828, u'doc_count': 122}, {u'key': 2422738, u'doc_count': 66}, {u'key': 174648, u'doc_count': 65}, {u'key': 1928122, u'doc_count': 65}, {u'key': 2012556, u'doc_count': 62}, {u'key': 377819, u'doc_count': 56}, {u'key': 2856270, u'doc_count': 55}, {u'key': 1417120, u'doc_count': 48}, {u'key': 238278, u'doc_count': 47}], u'sum_other_doc_count': 2605917, u'doc_count_error_upper_bound': 32}}, u'timed_out': False}
elasticsearch.helpers.scan
,尝试获取如下数据。
res = elasticsearch.helpers.scan(elastic,
index='play_post',
scroll='2m',
query={
"size": 0,
"query": {
"range": {
"created_at": {
"gte": start_date,
"lte": end_date
}
},
},
"aggs": {
"group_by_post_id": {
"terms": {
"field": "post_id"
}
}
}
},
request_timeout=300)
post_id
的分数。
{u'sort': [0], u'_type': u'play_post', u'_source': {u'post_id': 1281625, u'created_at': u'2018-04-14T19:29:11', u'user_id': 377765}, u'_score': None, u'_index': u'play_post', u'_id': u'd45d181c-0d2f-4bc9-aaa8-46fa5c41b748'}
{u'sort': [0], u'_type': u'play_post', u'_source': {u'post_id': 1632815, u'created_at': u'2018-04-15T13:09:56', u'user_id': 78467}, u'_score': None, u'_index': u'play_post', u'_id': u'cd279f13-42ee-4981-97c7-c18668a9b624'}
{u'sort': [0], u'_type': u'play_post', u'_source': {u'post_id': 1135965, u'created_at': u'2018-04-15T11:58:54', u'user_id': 318212}, u'_score': None, u'_index': u'play_post', u'_id': u'475f7199-4b20-4484-959a-873c38660180'}
.....
...
..
.
最佳答案
Scroll
查询没有得分,因为它可以扩展到如此大量的文档。同样在ES项目的github页面中,有人对此行为感到恼火:https://github.com/olivere/elastic/issues/661
要获得与带分数的滚动查询相同的结果,但要慢一点,可以使用search after
查询-doc here。您只需要一个日期字段和另一个唯一标识文档的字段-足够_id
字段或_uid
字段。看看这个答案:Elastic search not giving data with big number for page size
关于python - 如何使用elasticsearch.helpers.scan获得聚合结果的分数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49977938/
link-to帮助程序返回以下错误: Uncaught Error: each doesn't match link-to - 5:10 模板:
默认情况下,ember-cli 生成的帮助程序如下所示: import Ember from 'ember'; export function boundLoc(input) { return i
我正在发现 .Net Core 标签助手,我只是想知道是否有任何标签助手可以复制 @Html.DisplayFor。我认为 label tag helper 复制了 @Html.DisplayName
在本地访问我的 Rails 应用程序时,加载任何页面时出现以下错误: /!\ FAILSAFE /!\ Tue Jul 06 15:08:17 -0500 2010 Status: 500 Inte
m.ResetDayComponent.WeightedAverageMethodID, DropDownData.AveragingMethodList(), "", new { @class =
我正在使用 yii\helpers\Url 助手来访问我网站的菜单中的 url。但是应该有一个 url 去另一个网站,比如 www.anothersite.com/action . 如何通过 yii\
我不确定这是否可能。 我有一堆@Helper位于 View 内以及其他 View 中: @helper ViewHelper1() { ... } @helper ViewHelper2() {
有没有办法在 @helper 声明中访问完整的 @Url 帮助程序对象? 我想做这样的事情...... @helper Button(System.Web.Mvc.ActionResult actio
ASP.Net MVC 6 引入了标签助手功能。 为什么我们应该使用标签助手而不是以前版本提供的 Helper 类? 最佳答案 引入标签助手有几个原因。 Scott Hanselman talks i
我正在尝试从我的 ember.js 应用程序中的另一个助手调用助手,但不知道 blazes 在 2.x 中如何执行此操作。作为引用,我使用 Ember 2.4 和 Ember-CLI。 有几个答案在旧
我想在 Twitter 意图按钮上使用一个图标。 "btn" %> 这可能吗? 页面上还有 2 个其他按钮使用 button_tag 助手,我可以将图标插入到这些按钮中。我应该将 button_to
我一直在基于 Scott Gu's post 在 Razor 中实现一些 @helper 函数,事情进展顺利。 但我想知道的是,是否可以从另一个调用一个 @helper。例如,我有以下助手显示 Dat
我需要创建自定义 html 辅助方法。据我所知有两种方式: 使用@helper razor 语法。 http://weblogs.asp.net/scottgu/archive/2011/05/12/
我刚刚从另一台计算机上克隆了一个我正在使用的存储库。当我尝试通过运行“rake db:migrate”进行数据库迁移时,出现以下错误: AbstractController::Helpers::Mis
我的助手是这样工作的: def some_help(in_string) in_string + " and more" end 但我希望它在输出之前对 执行操作,并且我一直按字面意思获取 字符本
除了在 .Net Core 2 中,我正在尝试解决这个问题。 Can I use a Tag Helper in a custom Tag Helper that returns html? ” 我想
是否可以在另一个 View 助手中使用 View 助手?我们必须查看助手: 帮助我1 use Zend\View\Helper\AbstractHelper; class HelpMe1 extend
Creating MVC3 Razor Helper like Helper.BeginForm() 说它可以使用扩展方法和实现 IDisposable 来完成。可以通过使用声明性 Razor 助手来
所以如果我有一个模板: {{foo}} 和模板助手: Template.myTemplate.foo = function() { blah = Session.get('blah');
我正在尝试为我的 Reddit 机器人运行代码。它可以毫无问题地登录 Reddit,但是当它到达这段代码时,它会抛出一个错误: all_comments = praw.helpers.flatten_
我是一名优秀的程序员,十分优秀!