RError.com

RError.com Logo RError.com Logo

RError.com Navigation

  • 主页

Mobile menu

Close
  • 主页
  • 系统&网络
    • 热门问题
    • 最新问题
    • 标签
  • Ubuntu
    • 热门问题
    • 最新问题
    • 标签
  • 帮助
主页 / user-19770

ilyaplot's questions

Martin Hope
ilyaplot
Asked: 2020-11-06 23:34:57 +0000 UTC

完成后如何在elasticsearch中搜索?

  • 0

在elasticsearch中实现了日志记录,在多个字段中实现了搜索。

curl -X GET 1.2.3.4:9200/logs/_search?pretty=true -H 'Content-Type: application/json' -d '{"size":30,"query":{"constant_score":{"filter":{"bool":{"must":[{"terms":{"ident.keyword":["sip"]}}]}}}},"post_filter":{"multi_match":{"query":"9998887722","fields":["message","loglevel","env","site","project","ident"]}},"sort":[{"@timestamp":"desc"}]}'

基本上,搜索是通过电话号码在日志中执行的。电话号码可以以 7、+7、8 开头,或者根本没有前缀。现在搜索是通过完全匹配进行的,因此您需要确切知道将数字以什么格式写入日志。我想输入一个不带前缀的数字并找到它的所有变体,例如+79998887722, 89998887722, 9998887722, 79998887722, A019998887722

是否可以以某种方式更改查询以按后缀搜索数据?

我在文档中没有找到 prefix_len 的反向类似物。

elasticsearch
  • 1 个回答
  • 10 Views
Martin Hope
ilyaplot
Asked: 2020-11-15 20:55:01 +0000 UTC

在 PostgreSQL 9 中插入一个 SQL 查询中的相关数据

  • 0

有一个带有 id 和数据的表 t1。有一个表 t2,其中包含 id、t1_id 和数据。有一个带有 t1_id c 数据的表 t3。

我需要提出以下要求:

with new_t1 as (
    insert into t1 (data) values ('test data') returnning id
)

insert into t2 (t1_id, data) values (select id from new_t1, 'Test data 1'), (select id from new_t1, 'Test data 2');


insrt into t3 (t1_id) values (--- Как мне получить здесь t1.id из первого insert?)

让我解释一下它是什么。我需要创建一个 .sql 文件,通过 t1.id 将数据放入 3 个相关表中。使用 with ,我可以插入两个表,但是如何在第三个查询中获取 t1.id ?

postgresql
  • 1 个回答
  • 10 Views
Martin Hope
ilyaplot
Asked: 2020-05-22 18:29:50 +0000 UTC

如何在 JavaScript 中对对象进行分组?

  • 0

我有一个数组:

[
    {"id":1, "name":"Melody 1", "artist":{"name": "Artist 1", "id":1}},
    {"id":2, "name":"Melody 2", "artist":{"name": "Artist 1", "id":1}}
]

我想收到

[
    {"id":1, "name": "Artist 1", "content": [
        {"id":1, "name":"Melody 1"},
        {"id":2, "name":"Melody 2"}
    ]}
]

我尝试了所有可以在 js 中找到的选项,但没有任何结果。您能告诉我如何执行此类操作吗?

javascript
  • 1 个回答
  • 10 Views
Martin Hope
ilyaplot
Asked: 2020-03-02 21:33:17 +0000 UTC

Yii2、ActiveRecord 和 PostgreSQL 中的表继承

  • 1

有一个公用表,表,,,realty都是从它继承而来的。已经为所有这些表创建了模型。继承与数据库中的相同。flathouseareaActiveRecord

这些表的数据编辑形式是通用的,但有些字段是不同的,每个模型中对这些字段都规定了验证规则。

问题是:如果选择是从共享表中进行的,那么返回所需模型实例的最正确方法是什么?我知道它应该是这样的:

  1. 从父表中获取元素
  2. 按字段定义元素表type
  3. 我们用所需表的模型替换模型对象,我们这样做refresh是为了获得额外的字段。

问题在第 3 点。如何更换没有拐杖的模型类?

php
  • 1 个回答
  • 10 Views
Martin Hope
ilyaplot
Asked: 2020-12-20 21:23:45 +0000 UTC

如何更改音频标签控件的颜色?

  • 9

有一个 html5 音频标签。我在 webkit 列表中找到了如何更改延时摄影的颜色,但没有找到如何更改控件的颜色。告诉我,您需要为哪个属性指定颜色? 在此处输入图像描述

UPD:例如,我从@Arsen指出的列表中取出所有参数我感兴趣的控件的颜色没有改变

audio::-webkit-media-controls-panel,
			audio::-webkit-media-controls-mute-button,
			audio::-webkit-media-controls-play-button,
			audio::-webkit-media-controls-timeline-container,
			audio::-webkit-media-controls-current-time-display,
			audio::-webkit-media-controls-time-remaining-display,
			audio::-webkit-media-controls-timeline,
			audio::-webkit-media-controls-volume-slider-container,
			audio::-webkit-media-controls-volume-slider,
			audio::-webkit-media-controls-seek-back-button,
			audio::-webkit-media-controls-seek-forward-button,
			audio::-webkit-media-controls-fullscreen-button,
			audio::-webkit-media-controls-rewind-button,
			audio::-webkit-media-controls-return-to-realtime-button,
			audio::-webkit-media-controls-toggle-closed-captions-button {
				background: yellow;
				color: yellow;
	
			}
<audio src="https://www.w3schools.com/html/horse.ogg" controls>

示例结果:

在此处输入图像描述

css
  • 1 个回答
  • 10 Views
Martin Hope
ilyaplot
Asked: 2020-12-12 16:20:28 +0000 UTC

Yii2 ActiveForm Ajax 验证并提交外部表单

  • 0

有以下构造:

$form = ActiveForm::begin([
    'id' => 'update-form',
    'enableAjaxValidation' => true,
]);
echo $form->field($model, 'name')->textInput();
ActiveForm::end();

<button type="submit" form="update-form">Сохранить</button>

从 HTML 的角度来看,表单元素可以在表单之外,但必须通过 form 属性引用它。单击按钮时,甚至发送了数据,但是ajax验证没有启动,我需要启动它。如果提交在表单内,则验证有效。如何正确地将提交与表单绑定以便 ajax 验证工作?

php
  • 2 个回答
  • 10 Views
Martin Hope
ilyaplot
Asked: 2020-11-15 21:05:31 +0000 UTC

如何在一个查询中按日期从另一个表中选择记录数?

  • 1

我正在尝试从一个表中选择分组数据并从另一个表中添加记录数。

表结构是这样的:

t1:
  id
  created_at (timestamp)
  price (double)

t2:
  id
  created_at (timestamp)
  type (enum(1,2))

我正在尝试提出这样的请求:

select
    date(t1.created_at) as date,
    t1.price,
    (select count(*) from t2 t21 where date(t1.created_at) = date(t21.created_at) and type = 1) as cnt1,
    (select count(*) from t2 t22 where date(t1.created_at) = date(t22.created_at) and type = 2) as cnt2
from t1
group by date, t1.price

我收到一个错误subquery uses ungrouped column "t1.created_at" from outer query

如何按日期从另一个表中选择计数?

postgresql
  • 1 个回答
  • 10 Views
Martin Hope
ilyaplot
Asked: 2020-09-21 01:09:38 +0000 UTC

帮助理解 php-ml 使用示例

  • 0

几个小时以来,我试图理解 php-ml 的示例。我不明白这个例子中发生了什么。网络是从格式的 csv 文件中训练的"Текст предложения","язык" 这是示例本身

$dataset = new CsvDataset('data/languages.csv', 1);
$vectorizer = new TokenCountVectorizer(new WordTokenizer());
$tfIdfTransformer = new TfIdfTransformer();
$samples = [];
foreach ($dataset->getSamples() as $sample) {
    $samples[] = $sample[0];
}
$vectorizer->fit($samples);
$vectorizer->transform($samples);
$tfIdfTransformer->fit($samples);
$tfIdfTransformer->transform($samples);
$dataset = new ArrayDataset($samples, $dataset->getTargets());
$randomSplit = new StratifiedRandomSplit($dataset, 0.1);
$classifier = new SVC(Kernel::RBF, 10000);
$classifier->train($randomSplit->getTrainSamples(), $randomSplit->getTrainLabels());
$predictedLabels = $classifier->predict($randomSplit->getTestSamples());
echo 'Accuracy: '.Accuracy::score($randomSplit->getTestLabels(), $predictedLabels);

目前尚不清楚数据在输入端的确切位置。我只知道输入是训练网络的数据。

如何将我的文本提交给输入并确定这句话用英语写成的可能性有多大?

这是示例本身的链接php-ml-examples/classification/languageDetection.php

并到图书馆https://github.com/php-ai/php-ml

php
  • 1 个回答
  • 10 Views
Martin Hope
ilyaplot
Asked: 2020-06-09 21:35:49 +0000 UTC

如何在 jQuery 中将新行加载到表中?

  • 1

假设我们有以下代码。单击链接时,应发送 ajax 请求。接收数据可能会花费很多时间,期间很容易有时间再点击 1-2 个链接。鉴于 $.ajax 异步工作,问题出现了。但是,如何通过单击加载数据的方式将指向元素的链接传递给错误和成功回调?

$(function(){

  $('table tr').on('click', 'td>a', function(){
    $(this).parent().parent().after('<tr>'
    +'<td>Additional row</td>'
    +'<td>Some data...</td>'
    +'<td>Some data...</td>'
   +'</tr>');
  });
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<table>
<tbody>
  <tr>
    <td><a href="#">Load additional rows</a></td>
    <td>Some data...</td>
    <td>Some data...</td>
   </tr>
   <tr>
    <td><a href="#">Load additional rows</a></td>
    <td>Some data...</td>
    <td>Some data...</td>
   </tr>
   <tr>
    <td><a href="#">Load additional rows</a></td>
    <td>Some data...</td>
    <td>Some data...</td>
   </tr>
   <tr>
    <td><a href="#">Load additional rows</a></td>
    <td>Some data...</td>
    <td>Some data...</td>
   </tr>
</tbody>
</table>

javascript
  • 1 个回答
  • 10 Views
Martin Hope
ilyaplot
Asked: 2020-03-24 16:17:07 +0000 UTC

如何从 PostgreSQL 中的父表移动记录?

  • 0

我有几个继承表:

  1. product
  2. smartphone
  3. tablet

表smartphone和tablet继承自product.
假设我在表中添加了一条记录smartphone,但后来我想将该记录移动到表中tablet。我需要保留所有外键、ID 和字段集。有可能吗?

postgresql
  • 1 个回答
  • 10 Views
Martin Hope
ilyaplot
Asked: 2020-02-06 22:02:42 +0000 UTC

如何用正则表达式替换包含字母的单词?

  • 2

我决定增加搜索的相关性。有一个搜索查询“树”和“树”。还有两个搜索结果。我想显示两个查询的两个搜索结果。

我唯一有足够知识的就是用替换树ё|елка,但我需要得到 ёлка|елка。对于此任务,我需要使用正则表达式来选择包含字母 ё 的整个单词。

$query = preg_replace("/(ё|е)/isu" ,"ё|е", $query);
// получаю ё|елка

你能告诉我如何选择整个单词吗?

php
  • 2 个回答
  • 10 Views
Martin Hope
ilyaplot
Asked: 2020-08-10 22:11:10 +0000 UTC

如何从 JSON 中按值选择

  • 7

有一个包含类型字段的表json。表格中填满了[123,854,12], [],之类的值[12,2142141,24]
如何在json中选择包含某个数字的行?
那些。如果我搜索12,那么我应该得到上面列出的值的两行。

postgresql
  • 3 个回答
  • 10 Views
Martin Hope
ilyaplot
Asked: 2020-08-01 23:44:26 +0000 UTC

如何从数组中提取数字范围?

  • 3

我已经痛苦了一个小时了,我无法从数组中选择范围。假设我们有一个数组[0,1,2,3,5,6,7,9,13,20]。我想得到一个字符串作为输出0-3,5-7,9,13,20。
我试图循环遍历数组并使用next破折号prev替换数字或添加逗号,但出现了一些垃圾。告诉我,这个任务可能有简单的算法或 Yii2 中的助手吗?

массивы
  • 3 个回答
  • 10 Views
Martin Hope
ilyaplot
Asked: 2020-07-29 19:58:01 +0000 UTC

如何为ON添加条件?

  • 2

没有办法在on上为依赖添加条件,有这么一个模型:

class Parent extends ActiveRecord
{
    public function getChild()
    {
        return $this->hasMany(Child::class, ['parent_id' => 'parent_id'])->alias('c');
    }
}

我得到这样的数据:

$query = Parent::find()
    ->alias('p')
    ->distinct()
    ->joinWith([
        'child c'
    ], true, 'inner join');

结果,请求看起来像这样:

select 
  p.* 
from parent p
inner join child c 
  on c.parent_id = p.parent_id

问题是我不知道如何获得这样的请求:

select 
  p.* 
from parent p
inner join child c 
  on c.parent_id = p.parent_id and c.is_disabled = false
php
  • 1 个回答
  • 10 Views

Sidebar

Stats

  • 问题 10021
  • Answers 30001
  • 最佳答案 8000
  • 用户 6900
  • 常问
  • 回答
  • Marko Smith

    我看不懂措辞

    • 1 个回答
  • Marko Smith

    请求的模块“del”不提供名为“default”的导出

    • 3 个回答
  • Marko Smith

    "!+tab" 在 HTML 的 vs 代码中不起作用

    • 5 个回答
  • Marko Smith

    我正在尝试解决“猜词”的问题。Python

    • 2 个回答
  • Marko Smith

    可以使用哪些命令将当前指针移动到指定的提交而不更改工作目录中的文件?

    • 1 个回答
  • Marko Smith

    Python解析野莓

    • 1 个回答
  • Marko Smith

    问题:“警告:检查最新版本的 pip 时出错。”

    • 2 个回答
  • Marko Smith

    帮助编写一个用值填充变量的循环。解决这个问题

    • 2 个回答
  • Marko Smith

    尽管依赖数组为空,但在渲染上调用了 2 次 useEffect

    • 2 个回答
  • Marko Smith

    数据不通过 Telegram.WebApp.sendData 发送

    • 1 个回答
  • Martin Hope
    Alexandr_TT 2020年新年大赛! 2020-12-20 18:20:21 +0000 UTC
  • Martin Hope
    Alexandr_TT 圣诞树动画 2020-12-23 00:38:08 +0000 UTC
  • Martin Hope
    Air 究竟是什么标识了网站访问者? 2020-11-03 15:49:20 +0000 UTC
  • Martin Hope
    Qwertiy 号码显示 9223372036854775807 2020-07-11 18:16:49 +0000 UTC
  • Martin Hope
    user216109 如何为黑客设下陷阱,或充分击退攻击? 2020-05-10 02:22:52 +0000 UTC
  • Martin Hope
    Qwertiy 并变成3个无穷大 2020-11-06 07:15:57 +0000 UTC
  • Martin Hope
    koks_rs 什么是样板代码? 2020-10-27 15:43:19 +0000 UTC
  • Martin Hope
    Sirop4ik 向 git 提交发布的正确方法是什么? 2020-10-05 00:02:00 +0000 UTC
  • Martin Hope
    faoxis 为什么在这么多示例中函数都称为 foo? 2020-08-15 04:42:49 +0000 UTC
  • Martin Hope
    Pavel Mayorov 如何从事件或回调函数中返回值?或者至少等他们完成。 2020-08-11 16:49:28 +0000 UTC

热门标签

javascript python java php c# c++ html android jquery mysql

Explore

  • 主页
  • 问题
    • 热门问题
    • 最新问题
  • 标签
  • 帮助

Footer

RError.com

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

帮助

© 2023 RError.com All Rights Reserve   沪ICP备12040472号-5