我有一个法语单词索引。我想对索引属性应用分析器。假设我有一处title房产,我想将其视为“法国房产”。我试过这个(在kibana中):
PUT thing/_mappings/thing
{
"properties": {
"title": {
"type": "text",
"analyzer": "french",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
但结果是:
{
"error": {
"root_cause": [
{
"type": "illegal_argument_exception",
"reason": "Mapper for [title] conflicts with existing mapping in other types:\n[mapper [title] has different [analyzer]]"
}
],
"type": "illegal_argument_exception",
"reason": "Mapper for [title] conflicts with existing mapping in other types:\n[mapper [title] has different [analyzer]]"
},
"status": 400
}
Run Code Online (Sandbox Code Playgroud)
我不明白为什么我有这个错误。如果我显示映射 ( GET thing/_mappings),它不包含现有的分析器(除非我误解了某些东西):
// …Run Code Online (Sandbox Code Playgroud) 这是一个原始SQL查询:
SELECT name, area, point(area) AS center FROM places;
Run Code Online (Sandbox Code Playgroud)
我想基于此查询获得一个Eloquent模型.这是模型:
class Place extends Model
{
protected $visible = ['name', 'area'];
}
Run Code Online (Sandbox Code Playgroud)
所以,center如果我运行此代码,我想获取属性:
return response()->json( Place::all() );
Run Code Online (Sandbox Code Playgroud)
center不见了.我不知道如何center在我的Place对象中添加属性.我不想在我的控制器中构建一个原始查询,是否有任何解决方案与mutator或类似的东西?(我唯一想说的是Place::all(),我真的想在控制器中使用Eloquent Model,而不是SQL查询).
我试图在 Lumen 上配置日志轮换,但我被卡住了。我知道如何用 Laravel 做到这一点,但是(再一次)我对 Lumen 迷失了方向。
我尝试将其添加到 中app/bootstrap.php,因为我在某处阅读了它:
$app->configureMonologUsing(function(Monolog\Logger $monolog) use ($app) {
$monolog->pushHandler(
new \Monolog\Handler\RotatingFileHandler($app->storagePath().'/logs/lumen.log', 5)
);
});
Run Code Online (Sandbox Code Playgroud)
我可以查看此错误:
Fatal error: Uncaught Error: Call to a member function error() on null in /x/vendor/laravel/lumen-framework/src/Exceptions/Handler.php:36
Stack trace:
#0 /x/app/Exceptions/Handler.php(36): Laravel\Lumen\Exceptions\Handler->report(Object(Symfony\Component\Debug\Exception\FatalThrowableError))
#1 /x/vendor/laravel/lumen-framework/src/Concerns/RegistersExceptionHandlers.php(123): App\Exceptions\Handler->report(Object(Symfony\Component\Debug\Exception\FatalThrowableError))
#2 /x/vendor/laravel/lumen-framework/src/Concerns/RegistersExceptionHandlers.php(51): Laravel\Lumen\Application->handleUncaughtException(Object(Symfony\Component\Debug\Exception\FatalThrowableError))
#3 [internal function]: Laravel\Lumen\Application->Laravel\Lumen\Concerns\{closure}(Object(Error))
#4 {main}
thrown in /x/vendor/laravel/lumen-framework/src/Exceptions/Handler.php on line 36
Run Code Online (Sandbox Code Playgroud)
我不明白这是什么意思,我应该做什么。
有没有人在lumen 5.2中成功旋转登录?
我尝试从为 structure 实现的方法 调用闭包。我读了一些关于这个的帖子,但我现在有点迷失了。这是一个简化版本:do_somethingA
// A simple structure
struct A<F> {
f: F,
}
// Implements new and do_something
impl<F> A<F> where F: Fn() {
fn new(f: F) -> A<F> {
A { f: f }
}
fn do_something(&self) {
self.f() // Error is here.
}
}
fn main() {
let a = A::new( || println!("Test") );
a.do_something()
}
Run Code Online (Sandbox Code Playgroud)
它显示此错误:
错误:在当前范围内
f找不到为类型命名的方法&A<F>
我以为闭包就是这样调用的,但似乎我错过了一些东西。我试图self.f()用self.f.call()(没有真正理解的随机测试)替换,但它说明了两件事:
- 错误:此函数采用 1 个参数,但提供了 0 个参数
- 错误:显式使用未装箱的闭包方法 …
我尝试将解包的字符串引用发送到为结构实现的静态方法。这是一个简化的代码:
fn main() {
let a = A {p: Some("p".to_string())};
a.a();
}
struct A {
p: Option<String>
}
impl A {
fn a(self) -> Self {
Self::b(&self.p.unwrap());
self
}
fn b(b: &str) {
print!("b: {}", b)
}
}
Run Code Online (Sandbox Code Playgroud)
它失败:
fn main() {
let a = A {p: Some("p".to_string())};
a.a();
}
struct A {
p: Option<String>
}
impl A {
fn a(self) -> Self {
Self::b(&self.p.unwrap());
self
}
fn b(b: &str) {
print!("b: {}", b)
}
}
Run Code Online (Sandbox Code Playgroud)
我认为实施Copy特征不是解决方案。在那种情况下, …
DatabaseTransactionsDatabaseMigrations在 Laravel 测试中,trait 似乎比trait更快。这是正常的,因为每次测试DatabaseMigrations都会再次运行所有迁移过程(+回滚),并且DatabaseTransactions只是取消最后一个事务。DatabaseTransactions那么选择特质似乎是明智的。
不过,DatabaseMigrations确实存在。那么,使用它(而不是使用DatabaseTransactions)有什么好处吗?
有没有办法在表格中设置td宽度td.例如:
td,那么每个的宽度td是100%td,那么每个的宽度td是50%td,那么每个的宽度td是1/3有没有办法为这种需要编写CSS规则?
旁注:我无法编辑HTML,它来自其他地方.我只能编辑CSS.
HTML可能如下所示:
<table>
<tr>
<td>foo</td>
<td>bar</td>
<td>baz<td>
</tr>
</table>
Run Code Online (Sandbox Code Playgroud) 这是两个对象:
const obj1 = {a: null, b: "b"}
const obj2 = {a: "a", b: null}
Run Code Online (Sandbox Code Playgroud)
如何合并两个对象并获得以下对象?
{a: "a", b: "b"}
Run Code Online (Sandbox Code Playgroud)
我可以做这个:
const merged = {...obj1, ...obj2}
Run Code Online (Sandbox Code Playgroud)
但它返回以下内容:
{ a: "a", b: null }
Run Code Online (Sandbox Code Playgroud)
有没有一种方法可以合并两个对象,同时优先选择不为null(也不为空,未定义等)的值?
如果我用 Express 执行此操作,则会失败:
res.send(13245)
Run Code Online (Sandbox Code Playgroud)
它说:
表达已弃用的 res.send(status):使用 res.sendStatus(status) 代替 src/x.js:38:9 (节点:25549) UnhandledPromiseRejectionWarning:RangeError [ERR_HTTP_INVALID_STATUS_CODE]:无效状态代码:13245
这是因为它认为13245可能是一个状态代码。我还是想回去13245,有什么办法吗?
laravel ×3
php ×3
rust ×3
javascript ×2
laravel-5 ×2
css ×1
eloquent ×1
express ×1
html ×1
html-table ×1
kibana ×1
laravel-5.4 ×1
lumen ×1
lumen-5.2 ×1
mapping ×1
node.js ×1
postgresql ×1
structure ×1
unit-testing ×1