我在查询数组中的对象时遇到问题.让我们创建一个非常简单的索引,添加一个带有一个字段的类型,并添加一个带有对象数组的文档(我使用感应控制台):
PUT /test/
PUT /test/test/_mapping
{
"test": {
"properties": {
"parent": {"type": "object"}
}
}
}
Post /test/test
{
"parent": [
{
"name": "turkey",
"label": "Turkey"
},
{
"name": "turkey,mugla-province",
"label": "Mugla (province)"
}
]
}
Run Code Online (Sandbox Code Playgroud)
现在我想通过这两个名称进行搜索"turkey"
和"turkey,mugla-province"
.第一个查询工作正常:
GET /test/test/_search {"query":{ "term": {"parent.name": "turkey"}}}
但第二个没有回报:
GET /test/test/_search {"query":{ "term": {"parent.name": "turkey,mugla-province"}}}
我尝试了很多东西,包括:
"parent": {
"type": "nested",
"include_in_parent": true,
"properties": {
"label": {
"type": "string",
"index": "not_analyzed"
},
"name": {
"type": "string",
"store": true
}
}
}
Run Code Online (Sandbox Code Playgroud)
但没有任何帮助.我错过了什么?
npm项目的依赖关系:
"dependencies": {
"angular-chart.js": "1.1.0",
"angular-cookies": "1.5.7",
"angular-ui-bootstrap": "2.4.0",
"angular-ui-grid": "4.0.5",
"checklist-model": "0.10.0",
"json-schema": "0.2.2"
}
Run Code Online (Sandbox Code Playgroud)
并npm install
停止使用以下错误:
npm ERR! code ETARGET
npm ERR! notarget No matching version found for require-from-string@^1.1.0
npm ERR! notarget In most cases you or one of your dependencies are requesting
npm ERR! notarget a package version that doesn't exist.
npm ERR! notarget
npm ERR! notarget It was specified as a dependency of 'cosmiconfig'
npm ERR! notarget
Run Code Online (Sandbox Code Playgroud)
怎么解决?
我无法使用 spring-webflux 和 r2dbc (使用 r2dbc-pool driver 0.8.0.M8
)打开超过 10 个连接。我的配置如下:
@Configuration
public class PostgresConfig extends AbstractR2dbcConfiguration {
@Override
@Bean
public ConnectionFactory connectionFactory() {
ConnectionFactory connectionFactory = ConnectionFactories.get(ConnectionFactoryOptions.builder()
.option(DRIVER, "pool")
.option(PROTOCOL, "postgresql")
.option(HOST, host)
.option(USER, user)
.option(PASSWORD, password)
.option(DATABASE, database)
.build());
ConnectionPoolConfiguration configuration = ConnectionPoolConfiguration.builder(connectionFactory)
.maxIdleTime(Duration.ofMinutes(30))
.initialSize(initialSize)
.maxSize(maxSize)
.maxCreateConnectionTime(Duration.ofSeconds(1))
.build();
return new ConnectionPool(configuration);
}
}
Run Code Online (Sandbox Code Playgroud)
当我指定超过 10 个连接时,我会收到如下错误:
org.springframework.dao.DataAccessResourceFailureException:
Failed to obtain R2DBC Connection; nested exception is
java.util.concurrent.TimeoutException:
Did not observe any item or terminal signal within 1000ms in 'lift' …
Run Code Online (Sandbox Code Playgroud) 我正在将我的应用程序从spring boot 1.5.x迁移到2.0.x. 我想保持jedis,但我的实例化有问题RedisCacheManager
.
现在构造函数签名是
RedisCacheManager(RedisCacheWriter cacheWriter, RedisCacheConfiguration defaultCacheConfiguration)
Run Code Online (Sandbox Code Playgroud)
但在此之前:
RedisCacheManager(RedisOperations redisOperations)
Run Code Online (Sandbox Code Playgroud)
我定义这个bean只RedisTemplate
在范围内:
@Bean
public RedisCacheManager redisCacheManager(RedisTemplate redisTemplate) {
HandleRedisCacheManager redisCacheManager = new HandleRedisCacheManager(redisTemplate);
redisCacheManager.setUsePrefix(true);
return redisCacheManager;
}
Run Code Online (Sandbox Code Playgroud)
它应该如何创建呢?
假设我有返回的函数,Future[Either[_, _]
我想在失败的情况下应用其中的一些函数,这意味着只将它们应用于左侧.简化的例子是:
def operation1: Future[Either[String, Int]] = Future.successful(Right(5))
def operation2: Future[Either[String, Int]] = Future.successful(Left("error"))
def operation2FallBackWork = Future.successful{
println("Doing some revert stuff")
Left("Error happened, but reverting was successful")
}
val res = for {
res1 <- EitherT.fromEither(operation1)
res2 <- EitherT.fromEither(operation2)//.leftFlatMap(operation2FallBackWork) -????
} yield res1 + res2
Await.result(res.toEither, 5 seconds)
Run Code Online (Sandbox Code Playgroud)
怎么实现呢?
我正在运行 http4s WS 示例:https : //github.com/http4s/http4s/blob/master/examples/blaze/src/main/scala/com/example/http4s/blaze/BlazeWebSocketExample.scala
我正在尝试从 google chrome 控制台连接到它:
var ws = new WebSocket("ws://localhost:8080/http4s/wsecho")
ws.send("Hi")
Run Code Online (Sandbox Code Playgroud)
但实际上我看不到任何消息。在控制台日志中我看到
Uncaught DOMException: Failed to execute 'send' on 'WebSocket': Still in CONNECTING state.
at <anonymous>:1:4
(anonymous) @ VM204:1
VM186:1 WebSocket connection to 'ws://localhost:8080/http4s/wsecho' failed: Connection closed before receiving a handshake response
Run Code Online (Sandbox Code Playgroud)
并且服务器日志不包含错误:
23:12:43 [blaze-nio1-acceptor] INFO o.h.blaze.channel.ServerChannelGroup - Connection to /127.0.0.1:59777 accepted at Tue Mar 20 23:12:43 GST 2018.
23:12:43 [blaze-nio-fixed-selector-pool-3] DEBUG org.http4s.blaze.pipeline.Stage - SocketChannelHead starting up at Tue Mar 20 23:12:43 GST 2018 …
Run Code Online (Sandbox Code Playgroud) java ×2
scala ×2
angularjs ×1
bower ×1
http4s ×1
jedis ×1
npm ×1
npm-install ×1
r2dbc ×1
redis ×1
scalaz ×1
spring-boot ×1
spring-data ×1
websocket ×1