Spring Data ElasticSearch using QueryDSL | Java Techie

  Рет қаралды 27,417

Java Techie

Java Techie

5 жыл бұрын

This video will explain you how to perform Query DSL operation using spring data elasticsearch & ELasticSearchTemplate
#JavaTechie #SpringDataElasticSearch #QueryDSL
GitHub:
github.com/Java-Techie-jt/spr...
Blogs:
javagyanmantra.wixsite.com/we...
Facebook:
/ 919464521471923
Like and subscribe

Пікірлер: 74
@MohitSaini-tv8go
@MohitSaini-tv8go Ай бұрын
Awesome Explanation Basant !!!Thanks!!!
@Gautam_kumar_200
@Gautam_kumar_200 Жыл бұрын
Awesome man
@waxylayer8353
@waxylayer8353 2 жыл бұрын
You are the best in spring boot
@atharhussain9223
@atharhussain9223 3 жыл бұрын
Very helpful video< Thanks keep it up
@ravikumar-it1xm
@ravikumar-it1xm 4 жыл бұрын
Thank you, brother, you are super
@jyotiranjan5096
@jyotiranjan5096 3 жыл бұрын
Amazing Tutorial !
@armentovmasyan5029
@armentovmasyan5029 4 жыл бұрын
Thank you !
@TheVishnuvnv
@TheVishnuvnv 2 жыл бұрын
Great Video, appreciate your efforts! :)
@NishantKumar-vk1ic
@NishantKumar-vk1ic 2 жыл бұрын
Amazing Video ... Can you please upload a video on sum and group by with multiple columns in elastic search. That will be a great help. If you have already done, you can share me the link
@andreaschristou6952
@andreaschristou6952 5 жыл бұрын
Amazing video again! Thank you for that! Could you upload a video about parsing a JSON file using spring boot? Thank you!
@Javatechie
@Javatechie 5 жыл бұрын
Sure will do that
@javokhirnarzullayev
@javokhirnarzullayev 3 жыл бұрын
Okay
@ngalula
@ngalula 5 жыл бұрын
Nice tutorial. You should make a extended course on Udemy
@waxylayer8353
@waxylayer8353 2 жыл бұрын
Totally agree with you ! I would definitely buy it !
@raginikalvade1025
@raginikalvade1025 3 жыл бұрын
Nice tutorial. I have a question on how can I add other elasticsearch features such as highlight or autocomplete here?
@RajeevKumar-yh8hd
@RajeevKumar-yh8hd 3 жыл бұрын
thanks bhai
@muhammadharisasif1228
@muhammadharisasif1228 5 жыл бұрын
Amazing Job! I have one question that why you did not use Spring Boot 2? There is no node builder in the latest elastic version and there is no other way to do the same stuff with the latest elasticsearch and spring boot 2??
@Javatechie
@Javatechie 5 жыл бұрын
Hi Asif , spring boot 2x is not compatible with Elastic Search that's why I used lower version ... I googled it but didn't find solution to work with spring boot 2.x with Elastic Search
@nirmalsurana2720
@nirmalsurana2720 2 жыл бұрын
You can use following code instead: @Bean public RestHighLevelClient client() { ClientConfiguration clientConfiguration = ClientConfiguration.builder().connectedTo("localhost:9200").build(); return RestClients.create(clientConfiguration).rest(); }
@ShubhamYadav-fl4eb
@ShubhamYadav-fl4eb 4 жыл бұрын
Very nice tutorial. but how can we connect to the datasource to get data in elasticsearch??
@rappi1597
@rappi1597 5 жыл бұрын
Hi ,How to achieve the Facet ,When I search I need to get highlighted,and I need to get the suggestions
@udayshankar4780
@udayshankar4780 4 жыл бұрын
can we connect to the datasource to get data in elasticsearch and perform search operations .. Please tell me @javaTechie
@anandkumar-ko5ok
@anandkumar-ko5ok 4 жыл бұрын
what is the alternate solution if we don't want to lower spring version
@codesurmay
@codesurmay Жыл бұрын
this native search query builder and some methods are deprecated one so can you please make a another video explaining newer things
@Javatechie
@Javatechie Жыл бұрын
Yes buddy i will
@prateekashtikar8631
@prateekashtikar8631 3 жыл бұрын
I am using Spring Boot 2.2.7.RELEASE and Java 8, which version of elastic search we should be using ?
@Javatechie
@Javatechie 3 жыл бұрын
Am not sure about compatible version
@vansh1156
@vansh1156 Жыл бұрын
Nice video , Sir i want to write fuzzy query in java and not able to write it would you tell me what will be query for it
@basappakarlatthe1006
@basappakarlatthe1006 2 жыл бұрын
Hi Basant can you update this example with new versions of spring boot and elasticsearch...
@Javatechie
@Javatechie 2 жыл бұрын
Yes i will do that
@kesavulup6829
@kesavulup6829 4 жыл бұрын
hi sir, when I run the spring boot project then it showing below error [Scintilla] failed to get node info for {#transport#-1}{localhost}{127.0.0.1:9300}, disconnecting... org.elasticsearch.transport.NodeDisconnectedException: [][127.0.0.1:9300][cluster:monitor/nodes/liveness] disconnected
@rakeshranjan2798
@rakeshranjan2798 3 жыл бұрын
can u pls explain with multiple conditions...? e.g: like, IN/NOT-IN, equal, greaterThan, lessThan etc with a single query..
@dbgamer5200
@dbgamer5200 4 жыл бұрын
Can you please explain how to connect x-pack enabled elastic search from simple console based java application.It would be very grateful..:)
@Javatechie
@Javatechie 4 жыл бұрын
Ok I'll check and let you know
@amitsinha4159
@amitsinha4159 4 жыл бұрын
Hello Sir, Could you please create a video for below use case, I need your help for below use case. By watching your videos got some clarity on spring data elastic search. Use case :- Say, We have a movie booking application where I want to fetch the movies in sorted order based on most visited / search movies by user and most visited global movies with out user login. For this may need to implement logic to get max score and document wise scores but I am not aware with this how to do in springboot. Thanks in Advance
@rajaprabhu9215
@rajaprabhu9215 3 жыл бұрын
Elastic search is unstructured right ? for a example in customer documents, one document has five field and another has 9 fields in that case the Customer Model defined in the Java wont fit right ?how to handle such thing pls explain
@Javatechie
@Javatechie 3 жыл бұрын
Didn't get your question
@rupeshkhade9140
@rupeshkhade9140 Жыл бұрын
NodeBuilder is deprecated pls make another video using QueryDSL
@mugdha_studyabroad
@mugdha_studyabroad 5 жыл бұрын
sir my program executed .there was a problem in spring suite .but now when I send POST in postman it is giving 404 not found error ./Getindex..please helpppppop
@Javatechie
@Javatechie 5 жыл бұрын
404 means url mismatch so please give proper URL
@vijayswaminathan2472
@vijayswaminathan2472 5 жыл бұрын
Thank you for posting this video. However, I am currently facing the following issue when I try to follow your github project. Tried implementing it for a simple department entity. The error that I keep getting is - org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'departmentController': Unsatisfied dependency expressed through field 'deptService'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'departmentService': Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Failed to create query method public abstract java.lang.Object org.springframework.data.elasticsearch.repository.ElasticsearchRepository.index(java.lang.Object)! No property index found for type Department! Can you help me with some pointers to resolve this query? Sample Code - /********** Elastic search repository repository *******************/ package com.app.mycompany.AgileCenterServices.services; import java.util.List; import org.springframework.data.elasticsearch.repository.ElasticsearchRepository; import org.springframework.stereotype.Repository; @Repository public interface DepartmentService extends ElasticsearchRepository { List searchDepartment(String searchQuery); } /********** JPA repository *******************/ package com.app.mycompany.AgileCenterServices.repository; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.data.jpa.domain.Specification; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Repository; import com.app.mycompany.AgileCenterServices.entities.Department; @Repository public interface DepartmentRepository extends JpaRepository { Department findByName(String name); Page findAll(Specification spec, Pageable pageable); } /********** Elastic search configuration *******************/ package com.app.mycompany.AgileCenterServices.config; import java.io.IOException; import org.elasticsearch.node.NodeBuilder; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.data.elasticsearch.core.ElasticsearchOperations; import org.springframework.data.elasticsearch.core.ElasticsearchTemplate; import org.springframework.data.elasticsearch.repository.config.EnableElasticsearchRepositories; @Configuration @EnableElasticsearchRepositories(basePackages = "com.app.mycompany.AgileCenterServices.services") public class EsConfig { @Bean public NodeBuilder builder() { return new NodeBuilder(); } @Bean public ElasticsearchOperations elasticsearchTemplate() throws IOException { return new ElasticsearchTemplate(builder().local(true).node().client()); } } /********** Department entity *******************/ package com.app.mycompany.AgileCenterServices.entities; import javax.persistence.Column; import org.springframework.data.elasticsearch.annotations.Document; import javax.persistence.Entity; import javax.persistence.EntityListeners; import javax.persistence.GeneratedValue; import javax.persistence.Id; import javax.persistence.Table; import org.hibernate.annotations.GenericGenerator; import org.springframework.context.annotation.Scope; import org.springframework.data.jpa.domain.support.AuditingEntityListener; @Entity @Table(name="department") @Document(indexName="department") @EntityListeners(AuditingEntityListener.class) @Scope("session") public class Department { @Id @GenericGenerator(name = "sequence_department_id", strategy = "com.app.mycompany.AgileCenterServices.util.DepartmentIdGenerator") @GeneratedValue(generator = "sequence_department_id") @Column(unique = true) private String id; private String name; private String location; private String costCenter; public Department() {} public Department(String id, String name, String location, String costCenter) { super(); this.id = id; this.name = name; this.location = location; this.costCenter = costCenter; } public String getId() { return id; } public void setId(String id) { this.id = id; } public String getName() { return name; } public void setName(String name) { this.name = name; } public String getLocation() { return location; } public void setLocation(String location) { this.location = location; } public String getCostCenter() { return costCenter; } public void setCostCenter(String costCenter) { this.costCenter = costCenter; } @Override public String toString() { return "Department [id=" + id + ", name=" + name + ", location=" + location + ", costCenter=" + costCenter + "]"; } }
@Javatechie
@Javatechie 5 жыл бұрын
Did you follow Same what I did in this tutorial ? It would be more helpful if you add your code in Github and share link here so that I can check it out .
@sarojsahoo8763
@sarojsahoo8763 4 жыл бұрын
Why jna dependency is required !
@ashwinraghunath4453
@ashwinraghunath4453 4 жыл бұрын
hey in the last video why did we not need the config class?
@Javatechie
@Javatechie 4 жыл бұрын
Are you asking in this tutorial
@ashwinraghunath4453
@ashwinraghunath4453 4 жыл бұрын
@@Javatechie yes. In this tutorial we made a configuration class and in old elasticsearch tutorial we did not make configuration class and node builder. Why?
@JitendraSingh-tj6pm
@JitendraSingh-tj6pm 4 жыл бұрын
Can make video for JPA projections , JPA transaction and JPA query DSL . please
@Javatechie
@Javatechie 4 жыл бұрын
Will do
@JitendraSingh-tj6pm
@JitendraSingh-tj6pm 4 жыл бұрын
@@Javatechie please update soon Any link for jpa transaction I have to do one POC
@Javatechie
@Javatechie 4 жыл бұрын
I will update tomorrow , could you please remind this on javatechie4u@gmail.com
@rakeshranjan2798
@rakeshranjan2798 3 жыл бұрын
How we can use IN/NOT-IN like oracle..? e.g: fieldName IN ("val1", "val2","val3")
@GAneshStudyGAng
@GAneshStudyGAng 3 жыл бұрын
How to enable elastic query logs?
@ravisharma3275
@ravisharma3275 4 жыл бұрын
I followed your tutorial thoughrouhy but at the time of running the program it's showing application couldn't start i think because of version changing of my spring boot can you tell me any alternative so that i can get rid of this my version is 2.2.4
@Javatechie
@Javatechie 4 жыл бұрын
Yes it's due to version can you try with lower version or just create an issue in GitHub
@fabiostrada1510
@fabiostrada1510 5 жыл бұрын
It's possible make a "query + aggregations" using Spring data elasticsearch?
@Javatechie
@Javatechie 5 жыл бұрын
Yes we can
@fabiostrada1510
@fabiostrada1510 5 жыл бұрын
@@Javatechie I'm looking for to build a query with aggregation, but I don't find a solution.
@Javatechie
@Javatechie 5 жыл бұрын
Let me check if I can , just share your requirement please
@seagull_family4860
@seagull_family4860 3 жыл бұрын
Hi sir ,I am getting status: 500 and nonodeavailableexception throwing sir pls help me sir to solve this pblm
@RaviSavarapu
@RaviSavarapu Жыл бұрын
Nice video, I have one doubt. Why you use net.java.dev.jna
@udyanshardhar1532
@udyanshardhar1532 3 жыл бұрын
so there is no need to create indexes?
@Javatechie
@Javatechie 3 жыл бұрын
It's required
@udyanshardhar1532
@udyanshardhar1532 3 жыл бұрын
But you did not created index or used indexes while fetching from ES.
@arghyamitra3281
@arghyamitra3281 4 жыл бұрын
Sir how it is done using latest spring version ? I mean full text search ,
@Javatechie
@Javatechie 4 жыл бұрын
Are you getting any issue /error
@arghyamitra3281
@arghyamitra3281 4 жыл бұрын
@@Javatechie actually sir our team is using spring version 2.2.5 , there nodeBuilder not recognised
@Javatechie
@Javatechie 4 жыл бұрын
@@arghyamitra3281 it shouldn't lead any issue We might need to add some additional configuration as in each release version spring developer doing configuration changes.
@arghyamitra3281
@arghyamitra3281 4 жыл бұрын
@@Javatechiesir the spring version 1.5.9 is not compatible with Elk 6.5.1(latest) , maven build failing
@Javatechie
@Javatechie 4 жыл бұрын
Please do update your spring boot version
@sadhanapriyadarshini9826
@sadhanapriyadarshini9826 3 жыл бұрын
With Spring Boot 2 there is some changes required : import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.elasticsearch.core.SearchHits; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RestController; @RestController public class QueryDSLController { @Autowired private QueryDSLService service; @GetMapping("/serachMultiField/{firstname}/{age}") public SearchHits serachByMultiField(@PathVariable String firstname, @PathVariable int age) { return service.searchMultiField(firstname, age); } @GetMapping("/customSearch/{firstName}") public SearchHits getCustomerByField(@PathVariable String firstName) { return service.getCustomerSerachData(firstName); } @GetMapping("/search/{text}") public SearchHits doMultimatchQuery(@PathVariable String text) { return service.multiMatchQuery(text); } } ----------------------------------- import org.elasticsearch.index.query.MultiMatchQueryBuilder; import org.elasticsearch.index.query.QueryBuilder; import org.elasticsearch.index.query.QueryBuilders; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.elasticsearch.core.ElasticsearchRestTemplate; import org.springframework.data.elasticsearch.core.SearchHits; import org.springframework.data.elasticsearch.core.query.NativeSearchQuery; import org.springframework.data.elasticsearch.core.query.NativeSearchQueryBuilder; import org.springframework.stereotype.Service; @Service public class QueryDSLService { @Autowired private ElasticsearchRestTemplate template; public SearchHits searchMultiField(String firstname, int age) { QueryBuilder query = QueryBuilders.boolQuery().must(QueryBuilders.matchQuery("firstname", firstname)) .must(QueryBuilders.matchQuery("age", age)); NativeSearchQuery nativeSearchQuery = new NativeSearchQueryBuilder().withQuery(query).build(); SearchHits customers = template.search(nativeSearchQuery, Customer.class); return customers; } public SearchHits getCustomerSerachData(String input) { String search = ".*" + input + ".*"; NativeSearchQuery searchQuery = new NativeSearchQueryBuilder() .withFilter(QueryBuilders.regexpQuery("firstname", search)).build(); SearchHits customers = template.search(searchQuery, Customer.class); return customers; } public SearchHits multiMatchQuery(String text) { NativeSearchQuery searchQuery = new NativeSearchQueryBuilder().withQuery(QueryBuilders.multiMatchQuery(text) .field("firstname").field("lastname").type(MultiMatchQueryBuilder.Type.BEST_FIELDS)).build(); SearchHits customers = template.search(searchQuery, Customer.class); return customers; } } ---------------------------------------------- import org.elasticsearch.client.RestHighLevelClient; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.data.elasticsearch.client.ClientConfiguration; import org.springframework.data.elasticsearch.client.RestClients; import org.springframework.data.elasticsearch.core.ElasticsearchOperations; import org.springframework.data.elasticsearch.core.ElasticsearchRestTemplate; import org.springframework.data.elasticsearch.repository.config.EnableElasticsearchRepositories; @Configuration @EnableElasticsearchRepositories(basePackages = "com.subrat.ELK.repository") public class EsConfig { @Bean public RestHighLevelClient client() { ClientConfiguration clientConfiguration = ClientConfiguration.builder() .connectedTo("localhost:9200") .build(); return RestClients.create(clientConfiguration).rest(); } @Bean public ElasticsearchOperations elasticsearchTemplate() { return new ElasticsearchRestTemplate(client()); } }
SpringBoot ElasticSearch using Spring Data | Java Techie
21:40
Java Techie
Рет қаралды 95 М.
孩子多的烦恼?#火影忍者 #家庭 #佐助
00:31
火影忍者一家
Рет қаралды 1,5 МЛН
OMG🤪 #tiktok #shorts #potapova_blog
00:50
Potapova_blog
Рет қаралды 17 МЛН
New Elasticsearch Java Client: Getting Started, Usage, Examples & More
21:50
Official Elastic Community
Рет қаралды 10 М.
Spring Boot and ELK Integration | by Mr. Raghu
1:02:38
Naresh i Technologies
Рет қаралды 14 М.
Common Elastic Stack & Elasticsearch Architectures
10:58
Coding Explained
Рет қаралды 110 М.
Using Flyway for Managing Database Migrations in Spring Boot
22:38
Spring Boot and Elasticsearch Application
1:07:14
PixelTrice
Рет қаралды 21 М.
ПОКУПКА ТЕЛЕФОНА С АВИТО?🤭
1:00
Корнеич
Рет қаралды 3,1 МЛН
Урна с айфонами!
0:30
По ту сторону Гугла
Рет қаралды 7 МЛН
Samsung S24 Ultra professional shooting kit #shorts
0:12
Photographer Army
Рет қаралды 30 МЛН
Cadiz smart lock official account unlocks the aesthetics of returning home
0:30
Неразрушаемый смартфон
1:00
Status
Рет қаралды 1,7 МЛН