spring-data-elasticsearch

spring-data-elastic Id field not populated on reads when using CustomEntityMapper

人走茶凉 提交于 2019-12-24 00:43:45
问题 Elasticversion - 1.7.6 springboot - 1.3.5 Using spring-data-elasticsearch I have created a custom JSON mapping as advised elsewhere in order to support Java8 new datetime fields. This works fine - but breaks reading entities from the repository as the id field no longer gets populated. CustomConfig: @Bean @Autowired public ElasticsearchTemplate elasticsearchTemplate(Client client) { ObjectMapper objectMapper = new ObjectMapper(); objectMapper.registerModule(new JavaTimeModule()); return new

ElasticSearch in Spring with @Query

旧街凉风 提交于 2019-12-23 20:15:22
问题 I have successfully created a query using ElasticSearch's _plugin/head interface. The query is meant to return the latest timestamp for a specific device at a specific location. The query looks as follows: { "query":{ "bool":{ "must":[ { "term":{ "deviceevent.location.id":"1" } }, { "term":{ "deviceevent.deviceId":"AHE1LDD01" } } ] } }, "from":0, "size":1, "sort":{ "timestamp":{ "order":"desc" } } } The above query works as intended. Now using Spring-Boot and Spring-Data-ElasticSearch, I

Getting count and list of ids using ElasticsearchTemplate in spring-data-elasticsearch

怎甘沉沦 提交于 2019-12-23 17:00:37
问题 I am using spring-data-elasticsearch for a project to provide it with full text search functionality. We keep the real data in a relational database and relevant metadata along with respective id in elasticsearch. So for search results, only id field is required as the actual data will be retrieved from the relational database. I am building the search query based on search criteria and then performing a queryForIds(): SearchQuery searchQuery = new NativeSearchQueryBuilder() .withIndices

elasticsearch group by ID field and perform max on date field

风流意气都作罢 提交于 2019-12-23 05:27:53
问题 My index has data as mentioned below. Id version_number groupId indexDate 1 v1 1 2016-11-15T12:00:00 2 v1 2 2016-11-20T12:00:00 3 v2 2 2016-12-01T12:00:00 4 v1 3 2016-13-01T12:00:00 5 v1 4 2016-11-01T12:00:00 6 v2 4 2016-13-01T12:00:00 7 v1 5 2016-14-01T12:00:00 How can i write a elasticsearch query in java. If i search by date 2016-13-01T12:00:00 i expect to see the latest version per groupId which has indexDate less than or equal to the date searched? output expected: Id version_number

NPE while executing Update By Query in Elasticsearch using Java

て烟熏妆下的殇ゞ 提交于 2019-12-22 14:16:37
问题 I'm using Elasticsearch 2.4 in a Spring Boot application and I need to execute _update_by_query request to the remote ES instance using Java API. I've found the way to accomplish this task at this question, but as for my case I've got an NPE trying to execute the .get() function. A module for ES included: compile 'org.elasticsearch.module:reindex:2.4.1' Here's a code snippet I use for testing right now: UpdateByQueryRequestBuilder request = UpdateByQueryAction.INSTANCE.newRequestBuilder

Refreshing the ElasticSearch index from RDBMS using Spring Data

回眸只為那壹抹淺笑 提交于 2019-12-22 08:24:45
问题 I have the following setup : Mysql RDBMS server Elastic Search Server My requirement is to copy data periodically from MYSQL RDBMS and update Elastic server with it.Currently i am following the approach below : A Batch Job which reads all data from MYSQL using Spring Data Jpa It then pushes all data to elastic server using spring data elastic This approach is very cumbersome and not efficient.Is there a way where i can read only the updated values using spring data and update the index

Spring Data Elastic Search with Shield

*爱你&永不变心* 提交于 2019-12-21 20:55:51
问题 Does Spring Data Elastic Search template support username and password? What are the options to if we need to use spring data to connect to elastic search that is protected with Shield. Current configuration <elasticsearch:transport-client id="client" cluster-nodes="${elasticsearch.cluster.host}:${elasticsearch.cluster.port}" cluster-name="${elasticsearch.cluster.name}" /> <bean name="elasticsearchTemplate" class="org.springframework.data.elasticsearch.core.ElasticsearchTemplate">

Spring Data Elasticsearch's @Field annotation not working

我的梦境 提交于 2019-12-21 07:53:24
问题 I have a Spring Boot application with Spring Data Elasticsearch plugin in the pom.xml. I created a document class which i'd like to index: @Document(indexName = "operations", type = "operation") public class OperationDocument { @Id private Long id; @Field( type = FieldType.String, index = FieldIndex.analyzed, searchAnalyzer = "standard", indexAnalyzer = "standard", store = true ) private String operationName; @Field( type = FieldType.Date, index = FieldIndex.not_analyzed, store = true, format

Elasticsearch indexing not working and error message: node null not part of the cluster Cluster [elasticsearch], ignoring

一世执手 提交于 2019-12-21 07:20:37
问题 I just downloaded the elastic search distribution and ran it. curl 'localhost:9200' { "status" : 200, "name" : "cbs", "cluster_name" : "elasticsearch", "version" : { "number" : "1.4.1", "build_hash" : "89d3241d670db65f994242c8e8383b169779e2d4", "build_timestamp" : "2014-11-26T15:49:29Z", "build_snapshot" : false, "lucene_version" : "4.10.2" }, "tagline" : "You Know, for Search" } And I am trying to access it using spring-data. Added the following lines in application-context (as per spring

ElasticSearch returning only documents with distinct value

百般思念 提交于 2019-12-20 10:36:09
问题 Let's say I have this given data { "name" : "ABC", "favorite_cars" : [ "ferrari","toyota" ] }, { "name" : "ABC", "favorite_cars" : [ "ferrari","toyota" ] }, { "name" : "GEORGE", "favorite_cars" : [ "honda","Hyundae" ] } Whenever I query this data when searching for people who's favorite car is toyota, it returns this data { "name" : "ABC", "favorite_cars" : [ "ferrari","toyota" ] }, { "name" : "ABC", "favorite_cars" : [ "ferrari","toyota" ] } the result is Two records of with a name of ABC.