Spring上的Elasticsearch,Spring

Ipu*_*isa 2 java spring elasticsearch spring-boot jhipster

有人能举例说明在jHipsterSpring-boot中使用Elasticsearch吗?

我已经使用jHipster生成了实体.有占位符的输入:查询!

/**
     * SEARCH  /_search/samples/:query -> search for the sample corresponding
     * to the query.
     */
    @RequestMapping(value = "/_search/samples/{query}",
        method = RequestMethod.GET,
        produces = MediaType.APPLICATION_JSON_VALUE)
    @Timed
    public List<Sample> search(@PathVariable String query) {
        return StreamSupport
            .stream(sampleSearchRepository.search(queryString(query)).spliterator(), false)
            .collect(Collectors.toList());
    }
Run Code Online (Sandbox Code Playgroud)

如何使用elasticsearch?

这里有一些我在生成实体中找到的脚本!

我已经尝试过放置Object,q = field:value,弹性格式的数组,并且总是得到空数组.

抱歉英文不好!

Jul*_*don 5

好吧,你的索引似乎是空的.如果以编程方式添加实体(即不是从界面添加),请务必将它们保存在搜索存储库中.

示例:

Sample sample = new Sample();
sample.setName("bar");
sample = sampleRepository.save(sample);
sampleSearchRepository.save(sample);
Run Code Online (Sandbox Code Playgroud)

您需要重新生成样本以获取Hibernate生成的id在elasticsearch中正确索引.

更新2016年2月10日

现在有一个JHipster模块来重新索引elasticsearch存储库.