gpt4 book ai didi

java - 响应创建elasticsearch来自文件的响应期间出错

转载 作者:行者123 更新时间:2023-12-03 02:15:02 25 4
gpt4 key购买 nike

我尝试从文件创建响应以测试Elasticsearch服务

    def "FounderHint"() {
setup:
URL url = getClass().getClassLoader().getResource("elastic_response/elastic-founders-hint-response.json")
SearchResponse response = new SearchResponse().readFrom(url.openStream()) // this is a 40 line error

when: "we ask for hint"
elasticClient.search(any()) >> response
metrics.measureHintSearchTime(_) >> response

then: "we get list of ObjectHint"
List<ObjectHint> result = advancedSearchFilter.founderHint("але").collect(Collectors.toList())

result[0].inn == "323500905646"
result[0].name == "Алешина Екатерина Леонидовна"
但我得到错误-
No signature of method: org.elasticsearch.action.search.SearchResponse.readFrom() is applicable for argument types: (java.io.BufferedInputStream) values: [java.io.BufferedInputStream@19f135ca]
Possible solutions: readFrom(org.elasticsearch.common.io.stream.StreamInput), readFrom(org.elasticsearch.common.io.stream.StreamInput), readFrom(org.elasticsearch.common.io.stream.StreamInput)
groovy.lang.MissingMethodException: No signature of method: org.elasticsearch.action.search.SearchResponse.readFrom() is applicable for argument types: (java.io.BufferedInputStream) values: [java.io.BufferedInputStream@19f135ca]
Possible solutions: readFrom(org.elasticsearch.common.io.stream.StreamInput), readFrom(org.elasticsearch.common.io.stream.StreamInput), readFrom(org.elasticsearch.common.io.stream.StreamInput)
at ru.esphere.informator.refbook.retriever.hint.SearchExternalHintServiceTest.test external hint method for receive correct result(SearchExternalHintServiceTest.groovy:40)
SearchResponse是Elasticsearch类,它没有 setter ,是否有其他方法可以创建响应,或者我在哪里出错?

最佳答案

    BufferedInputStream stream = url.openStream()
SearchResponse response = new SearchResponse().readFrom(new StreamInput(stream))
将第一行的BufferedInputStream转换为StreamInput,然后再将其传递给readFrom

关于java - 响应创建elasticsearch来自文件的响应期间出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63777416/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com