Skip to content

Latest commit

 

History

History
33 lines (24 loc) · 1.1 KB

6-2_查询接口开发.md

File metadata and controls

33 lines (24 loc) · 1.1 KB

6-2 查询接口开发

  • 新增图书信息功能开发
  • 修改图书信息功能开发
  • 删除功能开发
  • 综合查询接口开发

代码

    // 查询接口
    @GetMapping("/get/book/novel")
    public ResponseEntity get(@RequestParam(name = "id", defaultValue = "") String id) {
        GetResponse response = client.prepareGet(BOOK_INDEX, BOOK_TYPE_NOVEL, id).get();
        if (!response.isExists()) {
            return new ResponseEntity(HttpStatus.NOT_FOUND);
        }
        return new ResponseEntity(response.getSource(), HttpStatus.OK);
    }

问题整理

  • org.elasticsearch.client.transport.NoNodeAvailableException: None of the configured nodes are available

    可以参考:解决JAVA访问Elasticsearch的问题

    主要有下面三点:

    1. 集群名称设置
    2. 集群IP和端口设置
    3. java 客户端和 elasticsearch 版本是否匹配