spring-data

Need to write a custom analyzer for ElasticsearchRepository findBy query

我们两清 提交于 2020-04-18 03:49:23
问题 I have an ES collection with following doc schema. ` public class Address { @Id private String id; private String name; private String type; private String city; } ` My repository looks like as follows: public interface NetworkElementsESRepository extends ElasticsearchRepository<Address, String> { Address findByNameAndCity(String name, String city);} I need to fetch all addresses with name= "B00/A3K/24" in a particular city using following Query. addressRepo.findByNameAndCity(Name,City) . I

Is there any way to write custom or native queries in Java JPA (DocumentDbRepository) while firing a query to azure-cosmosdb?

爱⌒轻易说出口 提交于 2020-04-17 21:25:47
问题 Connected to azure-cosmosdb and able to fire default queries like findAll() and findById(String Id) . But I can't write a native query using @Query annotation as the code is not considering it. Always considering the name of the function in respository class/interface. I need a way to fire a custom or native query to azure-cosmos db. ?! Tried with @Query annotation. But not working. List<MonitoringSessions> findBySessionID(@Param("sessionID") String sessionID); @Query(nativeQuery = true,

Elasticsearch analizer working when created throw Springdata but failing when creating straight from Postman/curl

拟墨画扇 提交于 2020-04-17 18:14:58
问题 Goal: create Elasticsearch index aimed to be loaded with 10 million simple documents. Each document is basically "Elastisearch id", "some company id" and "name". Provide search-as-suer-type feature. I could created successfully an index and an analyzer either straight from Postman (curl or any other tool not relying on Spring Data) or during Spring boot initialization. Nevertheless, when I try to use the analizer it seems it is ignored for the one created straight from Postman. So my main

Elasticsearch analizer working when created throw Springdata but failing when creating straight from Postman/curl

十年热恋 提交于 2020-04-17 17:57:54
问题 Goal: create Elasticsearch index aimed to be loaded with 10 million simple documents. Each document is basically "Elastisearch id", "some company id" and "name". Provide search-as-suer-type feature. I could created successfully an index and an analyzer either straight from Postman (curl or any other tool not relying on Spring Data) or during Spring boot initialization. Nevertheless, when I try to use the analizer it seems it is ignored for the one created straight from Postman. So my main

Passing fk in json via rest call as part of DerivedIdentities

别说谁变了你拦得住时间么 提交于 2020-04-16 04:15:08
问题 A short summary : I got a Product entity that has an embedded key (id,manufacturer). I'm passing through rest call the product entity with fk of the manufacturer : { "name":"Chocolate", "register_date":"19/03/2020", "manufacturer_id": 52, "rating":"Amazing" } When I try to save the entity in the controller I'm getting the following error java.lang.IllegalArgumentException: Can not set com.dao.Manufacturer field com.dao.ProductId.manufacturer to java.lang.Long Product : @Getter @Setter

How to write MongoTemplate Query and Criteria for a complex Document structure?

回眸只為那壹抹淺笑 提交于 2020-04-14 07:46:09
问题 I am new to MongoTemplate. I want to define a org.springframework.data.mongodb.core.query.Query and org.springframework.data.mongodb.core.query.Criteria to fetch the data from a collection which has a complex document structure. This is the document { "_id" : { "SId" : "ANBS", "AssetId" : "ANBS_BS21", "ST" : NumberLong(1479114000) //StartDate }, "ET" : NumberLong(1479117599) //EndDate, "TS" : [ NumberLong(1479114000), NumberLong(1479114600), NumberLong(1479115200), NumberLong(1479115800),

Spring Data Mongo: How to return nested object by its field?

感情迁移 提交于 2020-04-13 17:55:47
问题 I have domain: class Company { List<Job> jobs; } Is there a way to return nested object from collection like: @Repository public interface CompanyRepository extends MongoRepository<Company, String>{ Job findByJobId(String jobId); } 回答1: I have to make some assumptions about the structure of your Job model, but assuming something like this: public class Job { private String id; // other attributes and methods } ... and assuming that this model is embedded in your Company model, and not

Spring Data Mongo: How to return nested object by its field?

随声附和 提交于 2020-04-13 17:55:37
问题 I have domain: class Company { List<Job> jobs; } Is there a way to return nested object from collection like: @Repository public interface CompanyRepository extends MongoRepository<Company, String>{ Job findByJobId(String jobId); } 回答1: I have to make some assumptions about the structure of your Job model, but assuming something like this: public class Job { private String id; // other attributes and methods } ... and assuming that this model is embedded in your Company model, and not

Spring Data Mongo: How to return nested object by its field?

二次信任 提交于 2020-04-13 17:55:09
问题 I have domain: class Company { List<Job> jobs; } Is there a way to return nested object from collection like: @Repository public interface CompanyRepository extends MongoRepository<Company, String>{ Job findByJobId(String jobId); } 回答1: I have to make some assumptions about the structure of your Job model, but assuming something like this: public class Job { private String id; // other attributes and methods } ... and assuming that this model is embedded in your Company model, and not

Should Kotlin's DAO return Optional or null?

痞子三分冷 提交于 2020-04-12 19:46:40
问题 Prior to Kotlin/JPA , I used to write my DAO layer like this : public interface UserDao extends JpaRepository<User,Long> { Optional<User> findBySsn(String ssn); } And in the caller side , if I want to find someone or create user by SSN , I can write this: val user = userDao.findBySsn(value).orElseGet { userDao.save(value) } It works well and looks fluent. But since Kotlin introduces null-safety , there is another idiomatic way (dao still in Java ): public interface UserDao extends