问题描述
有人可以在 jHipster 或 Spring-boot 中使用弹性搜索吗?
Can someone give me example for using Elasticsearch in jHipster or in Spring-boot?
我已经使用jHipster生成了实体。有输入与占位符:查询!
I have already generated entity using jHipster. There are input with placeholder :query !
/**
* 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());
}
如何使用弹性搜索?
这里有一些脚本,我发现在生成的实体!
Here some script that i found in generated Entity!
我已经尝试放置对象, q =字段:值,具有弹性格式的数组,始终为空 Array 。
I have already tried placing Object, q=field:value, Array with elastic format and always got empty Array.
!
推荐答案
嗯,你的索引好像是空的如果您以编程方式(即不从界面)添加实体,请确保将它们保存在搜索库中。
Well, it seems that your index is empty. If you add entities programmatically (i.e. not from the interface), be sure to save them in the search repository as well.
示例:
Sample sample = new Sample();
sample.setName("bar");
sample = sampleRepository.save(sample);
sampleSearchRepository.save(sample);
您需要重新引用示例,以获取Hibernate生成的id在弹性搜索中正确索引。
You need to reaffect sample to get the id generated by Hibernate correctly indexed in elasticsearch.
更新10/02/2016
现在有一个。
这篇关于弹跳在Jhipster,春天的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!