spring-data-elasticsearch

Spring-Boot Elasticseach EntityMapper can not be autowired

戏子无情 提交于 2019-12-08 21:11:41
问题 Based on this answer and the comments I implemented the code to receive the scores of an elastic search query. public class CustomizedHotelRepositoryImpl implements CustomizedHotelRepository { private final ElasticsearchTemplate elasticsearchTemplate; @Autowired public CustomizedHotelRepositoryImpl(ElasticsearchTemplate elasticsearchTemplate) { super(); this.elasticsearchTemplate = elasticsearchTemplate; } @Override public Page<Hotel> findHotelsAndScoreByName(String name) { QueryBuilder

Spring Data Elasticsearch Parent/Child Document Repositories / Test execution error

*爱你&永不变心* 提交于 2019-12-08 18:43:42
问题 I created two Spring-Data elasticsearch repositories for two parent/child related documents. You can see the document classes for both of them here. The repositories are getting instantiated in XML with the help of repositories element like this <elasticsearch:repositories base-package="com.acme.repositories" /> You can find a complete example of the issue in this github repo. My source code is based in the tests found in spring-data-elasticsearch repo. The source code consists of just two

Cannot use custom autoconfiguration with spring-data-elasticsearch

不羁岁月 提交于 2019-12-08 16:38:09
问题 I am not able to get spring-data-elasticsearch working for Elasticsearch 2.0+ versions. On using following POM <?xml version="1.0" encoding="UTF-8"?> <project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <modelVersion>4.0.0</modelVersion> <groupId>com.project.treasure</groupId> <artifactId>search</artifactId> <version>1.0.0</version> <packaging

Spring data elasticsearch scan and scroll paged result is not working?

杀马特。学长 韩版系。学妹 提交于 2019-12-08 13:35:00
问题 I have problems using scan and scroll as the pages from scan return strange result. I am not using them exactly as stated in the documentation. In the method getAllExampleItems() I have a while loop on the "page.hasNext()" method, which always return false. The reason for that is the Pageable from the search query is not set on the result page, and the number of pages therefore is always 1. Another thing that is weird is that I set 100 as the result size and get 500 back! Isn't that a bug or

elasticsearch top hits aggregation java API query

六眼飞鱼酱① 提交于 2019-12-08 12:56:38
问题 I am running the below query and want to retrieve top hits per bucket. But I see multiple docs per bucket in few cases. I want only one document per bucket returned. Can some one review the query and suggest. SearchResponse sr=client.prepareSearch(versionIndexName).setTypes(versionIndexType).setQuery(Quer yBuilders.boolQuery().must(QueryBuilders.rangeQuery("indexDate").lte(givenTime))) .addAggregation(AggregationBuilders.terms("form.id").field("form.id").size(0) .subAggregation

ElasticSearch Indexing Key/Value Map

陌路散爱 提交于 2019-12-08 12:47:28
I'm using elasticsearch as indexing engine in my java project. I'm asking if there is anyway to index a java.util.Map a key/value Map. For example i have this java class: public class NextEvent extends NewtonResource{ private Map<String, String> metadata; private Instant executionDate; private String type; protected Boolean executed; private List<PatchOperation> jsonPatch; private List<String> crons; ... } I want to create an elasticsearch mapping including the Map of metadata variable. somethings like this: { "aliases": { "posc-alias-nextevent": {} }, "mappings": { "nextevent": { "properties"

How does ElasticSearch do nested range aggregation query

做~自己de王妃 提交于 2019-12-08 11:56:14
问题 ** I am trying to aggregate and find price ranges if on the basis of nested offer price array (nested Array) object of sellerInfoES. Internal field is "offerPrice". How I can write aggregation on the nested array field in Elasticsearch. I tried this following query, but it's not working. Getting this error: Parse Failure [Found two aggregation type definitions in [price_ranges]: [nested] and [filter]] Mapping: { "productsearch": { "mappings": { "product": { "properties": { "brand": { "type":

Spring Data elasticsearch @Query annotation for nested objects

£可爱£侵袭症+ 提交于 2019-12-08 10:13:28
问题 I have two class, @Document public class PracticeQuestion { private int userId; private List<Question> questions; // Getters and setters } public class Question { private int questionID; private String type; // Getters and setters } My JSON doc is like this, { "_id" : ObjectId("506d9c0ce4b005cb478c2e97"), "userId" : 1, "questions" : [ { "questionID" : 1, "type" : "optional" }, { "questionID" : 3, "type" : "mandatory" } ] } How should I write the query method to find PracticeQuestion by userId

Handling org.elasticsearch.client.transport.NoNodeAvailableException

☆樱花仙子☆ 提交于 2019-12-08 10:02:59
问题 Hi In my SpringBoot project i have configured elastic search using JPA. I am using ElasticsearchRepository for it. Now for the configuration when i am using localhost then everything works fine but when i am putting IP address then i am facing an exception- org.elasticsearch.client.transport.NoNodeAvailableException: None of the configured nodes are available: [{#transport#-1}{lDnuVli1Rriy-9j1pdozZA}{27.101.12.99}{27.101.12.99:9300}] at org.elasticsearch.client.transport

How to search inside all types in elastic index using spring data elasticsearch

一笑奈何 提交于 2019-12-08 08:14:35
问题 I'm building a search application in which I will have to search inside all types in specified index and specific type in specified index. Am using spring data elasticsearch as my java client for elasticsearch. But am getting no hits in the case where I have to search whole of the index(all types). Code snippets used for search :- Whole index(Returns 0 hits) :- SearchQuery searchQuery = new NativeSearchQueryBuilder() .withIndices(<index_name>) .withQuery(finalQuery) .withHighlightFields(field