我想知道:node.close()
当我们完成查询/搜索过程时,我们是否必须每次都打电话,或者就client.close()
可以了?这是我的代码:
val node =nodeBuilder().client(true).node()
val client =node.client()
val query = QueryBuilders.matchQuery(fieldName.toString(), q).fuzziness(Fuzziness.AUTO)//user can make 2 typo mistakes
val response = client.prepareSearch("arteciatedb")
.setTypes("readOnlyAdmin")
.setSearchType(SearchType.DFS_QUERY_THEN_FETCH)
.addFields("uuid","FirstName","LastName","Email","SecondryEmail","UserStatus","_source")
.setQuery(query)
.execute()
.actionGet()
val hits = response.getHits
totalHits=hits.getTotalHits
log.info("total search result {}",)
client.close()
node.close()
我经常运行这段代码;所以,之后node.close()
,下次我执行此代码时,它会再次启动节点(导致搜索响应延迟),这是不希望的。我想知道node.close()
当我们需要经常调用这个搜索代码时是否是正确的做法。