我正在使用弹性 RestHighLevelClient 与 ES 对话。我可以查询基本查询。但是,我正在尝试使用search_afterapi 从我的前端查询中设计分页 api。虽然query_after在 RestLowLevelClient api 中使用起来很简单,但我无法弄清楚如何在 HighLevel API 中使用它。
看起来 Lucene api 有 SearchAfterSortedDocQuery,但我不知道如何将它与弹性搜索 api 一起使用。例如:在下面的代码中,我初始化 SearchAfterSortedDocQuery 查询,但不确定如何使用它。
RestHighLevelClient client = ESRestClient.getClient();
SearchRequest searchRequest = new SearchRequest();
SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
searchSourceBuilder.query(QueryBuilders.termQuery("field1",value1));
searchSourceBuilder.query(QueryBuilders.termQuery("field2",value2));
searchSourceBuilder.from(0);
searchSourceBuilder.size(limit);
SortField[] sortFields = new SortField[2];
sortFields[0]= new SortField("field1", SortField.Type.LONG);
sortFields[1]= new SortField("field2", SortField.Type.LONG);
FieldDoc fieldDoc = new FieldDoc(0,0); //Is this correct? how to initialize field doc?
fieldDoc.fields = new Object[2];
fieldDoc.fields[0] = new Long("-156034");
fieldDoc.fields[1] = …Run Code Online (Sandbox Code Playgroud) 谁能告诉我如果我不实现onInit接口并且仍然在组件内使用ngOnInit组件生命周期会发生什么?
因为我在没有实现接口的情况下使用了ngOnInit生命周期钩子,它对我来说也是一样的。
所以只是想了解为什么我应该实现一个接口?
我有 Kafka 服务器版本 2.4 并设置log.retention.hours=168(这样主题中的消息将在 7 天后被删除)和auto.offset.reset=earliest(这样如果消费者没有得到最后一次提交offset 那么它应该从头开始处理)。由于我使用的是 Kafka 2.4 版本,因此默认值offsets.retention.minutes=10080(因为我没有在我的应用程序中设置这个属性)。
我的话题数据是:1,2,3,4,5,6,7,8,9,10
关闭消费者之前的当前消费者偏移量:10
结束偏移:10
消费者最后提交的偏移量:10
因此,假设我的消费者在过去 7 天内没有运行,而我在第 8 天启动了消费者。所以我最后一次提交的消费者偏移将过期(由于offsets.retention.minutes=10080属性)并且主题消息也将被删除(由于log.retention.hours=168属性)。
所以想知道现在auto.offset.reset=earliest属性将设置什么消费者偏移量?
我们正在使用 Minio 进行 S3 的本地测试,并且我们已经docker-compose file使用 Minio 创建了应用程序,并且我们的应用程序依赖项如下:
Docker 撰写文件:
version: "2.1"
services:
minio:
image: minio/minio
container_name: minio
ports:
- 9001:9001
volumes:
- minio_storage:/data
environment:
MINIO_ACCESS_KEY: minio
MINIO_SECRET_KEY: minio123
MINIO_REGION: us-east-1
command: server /data --console-address ":9001"
mem_limit: 512m
populate-minio-data:
container_name: "minio-data"
image: minio/mc
volumes:
- ./hello.txt:/tmp/hello.txt
entrypoint: >
/bin/sh -c "
/usr/bin/mc config host rm local;
/usr/bin/mc config host add --quiet --api s3v4 local http://minio:9001 minio minio123;
/usr/bin/mc mb --quiet local/somebucketname1/;
/usr/bin/mc policy set public local/somebucketname1;
/usr/bin/mc cp …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用 powermockito模拟CouchbaseCluster.create()的静态方法。这是我的测试课。
@PrepareForTest(CouchbaseCluster.class)
public class IAMKafkaConsumerTest extends PowerMockTestCase {
private IAMKafkaConsumer iamKafkaConsumer;
private CouchbaseCluster mockCouchbaseCluster;
private Bucket mockBucket;
@ObjectFactory
public IObjectFactory getObjectFactory() {
return new org.powermock.modules.testng.PowerMockObjectFactory();
}
@Test
public void happyPath()
{
PowerMockito.mockStatic(CouchbaseCluster.class);
}
}
Run Code Online (Sandbox Code Playgroud)
我的项目 pom 包括以下依赖项:
<dependency>
<groupId>cglib</groupId>
<artifactId>cglib</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-module-testng</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-module-testng-agent</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-api-mockito</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-module-junit4</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<scope>test</scope>
</dependency>
Run Code Online (Sandbox Code Playgroud)
当我通过 TestNG 框架运行测试时,我收到此错误日志。
java.lang.NoClassDefFoundError: org/mockito/internal/creation/CglibMockMaker …
amazon-s3 ×1
angular ×1
angular-component-life-cycle ×1
apache-kafka ×1
couchbase ×1
docker ×1
java ×1
lucene ×1
minio ×1
powermockito ×1
testng ×1