Spring Data ElasticSearch using QueryDSL | Java Techie

Spring Data ElasticSearch using QueryDSL | Java Techie

Java Techie

5 лет назад

27,740 Просмотров

Ссылки и html тэги не поддерживаются


Комментарии:

@andreaschristou6952
@andreaschristou6952 - 19.12.2018 14:46

Amazing video again! Thank you for that! Could you upload a video about parsing a JSON file using spring boot? Thank you!

Ответить
@muhammadharisasif1228
@muhammadharisasif1228 - 12.01.2019 03:37

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??

Ответить
@ngalula
@ngalula - 26.01.2019 15:35

Nice tutorial. You should make a extended course on Udemy

Ответить
@mugdha_studyabroad
@mugdha_studyabroad - 25.02.2019 20:27

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

Ответить
@rappi1597
@rappi1597 - 11.06.2019 06:28

Hi ,How to achieve the Facet ,When I search I need to get highlighted,and I need to get the suggestions

Ответить
@fabiostrada1510
@fabiostrada1510 - 26.06.2019 13:05

It's possible make a "query + aggregations" using Spring data elasticsearch?

Ответить
@ShubhamYadav-fl4eb
@ShubhamYadav-fl4eb - 10.08.2019 14:17

Very nice tutorial.
but how can we connect to the datasource to get data in elasticsearch??

Ответить
@ashwinraghunath4453
@ashwinraghunath4453 - 05.11.2019 12:54

hey in the last video why did we not need the config class?

Ответить
@ravisharma3275
@ravisharma3275 - 26.02.2020 21:46

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

Ответить
@ravikumar-it1xm
@ravikumar-it1xm - 17.03.2020 19:32

Thank you, brother, you are super

Ответить
@armentovmasyan5029
@armentovmasyan5029 - 30.04.2020 20:25

Thank you !

Ответить
@udayshankar4780
@udayshankar4780 - 07.05.2020 18:48

can we connect to the datasource to get data in elasticsearch and perform search operations .. Please tell me @javaTechie

Ответить
@sarojsahoo8763
@sarojsahoo8763 - 08.05.2020 18:15

Why jna dependency is required !

Ответить
@JitendraSingh.021
@JitendraSingh.021 - 16.05.2020 22:48

Can make video for JPA projections , JPA transaction and JPA query DSL . please

Ответить
@arghyamitra3281
@arghyamitra3281 - 25.05.2020 15:59

Sir how it is done using latest spring version ? I mean full text search ,

Ответить
@anandkumar-ko5ok
@anandkumar-ko5ok - 12.06.2020 17:57

what is the alternate solution if we don't want to lower spring version

Ответить
@amitsinha4159
@amitsinha4159 - 08.07.2020 19:06

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

Ответить
@udyanshardhar1532
@udyanshardhar1532 - 24.07.2020 09:03

so there is no need to create indexes?

Ответить
@warAlgorithmm
@warAlgorithmm - 31.07.2020 10:18

thanks bhai

Ответить
@atharhussain9223
@atharhussain9223 - 02.08.2020 11:05

Very helpful video< Thanks keep it up

Ответить
@prateekashtikar8631
@prateekashtikar8631 - 28.09.2020 14:27

I am using Spring Boot 2.2.7.RELEASE and Java 8, which version of elastic search we should be using ?

Ответить
@GAneshStudyGAng
@GAneshStudyGAng - 27.10.2020 11:07

How to enable elastic query logs?

Ответить
@sadhanapriyadarshini9826
@sadhanapriyadarshini9826 - 25.12.2020 12:54

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<Customer> serachByMultiField(@PathVariable String firstname, @PathVariable int age) {
return service.searchMultiField(firstname, age);
}

@GetMapping("/customSearch/{firstName}")
public SearchHits<Customer> getCustomerByField(@PathVariable String firstName) {
return service.getCustomerSerachData(firstName);
}

@GetMapping("/search/{text}")
public SearchHits<Customer> 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<Customer> 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<Customer> customers = template.search(nativeSearchQuery, Customer.class);
return customers;
}

public SearchHits<Customer> getCustomerSerachData(String input) {
String search = ".*" + input + ".*";
NativeSearchQuery searchQuery = new NativeSearchQueryBuilder()
.withFilter(QueryBuilders.regexpQuery("firstname", search)).build();
SearchHits<Customer> customers = template.search(searchQuery, Customer.class);
return customers;

}

public SearchHits<Customer> multiMatchQuery(String text) {

NativeSearchQuery searchQuery = new NativeSearchQueryBuilder().withQuery(QueryBuilders.multiMatchQuery(text)
.field("firstname").field("lastname").type(MultiMatchQueryBuilder.Type.BEST_FIELDS)).build();
SearchHits<Customer> 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());
}

}

Ответить
@javokhirnarzullayev
@javokhirnarzullayev - 24.01.2021 21:37

Okay

Ответить
@rajaprabhu9215
@rajaprabhu9215 - 15.02.2021 19:22

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

Ответить
@jyotiranjan5096
@jyotiranjan5096 - 25.03.2021 15:00

Amazing Tutorial !

Ответить
@rakeshranjan2798
@rakeshranjan2798 - 14.05.2021 16:16

How we can use IN/NOT-IN like oracle..?
e.g: fieldName IN ("val1", "val2","val3")

Ответить
@rakeshranjan2798
@rakeshranjan2798 - 14.05.2021 16:19

can u pls explain with multiple conditions...?
e.g: like, IN/NOT-IN, equal, greaterThan, lessThan etc with a single query..

Ответить
@seagull_family4860
@seagull_family4860 - 09.06.2021 09:28

Hi sir ,I am getting status: 500 and nonodeavailableexception throwing sir pls help me sir to solve this pblm

Ответить
@raginikalvade1025
@raginikalvade1025 - 24.06.2021 07:26

Nice tutorial. I have a question on how can I add other elasticsearch features such as highlight or autocomplete here?

Ответить
@waxylayer8353
@waxylayer8353 - 16.08.2021 21:26

You are the best in spring boot

Ответить
@NishantKumar-vk1ic
@NishantKumar-vk1ic - 27.08.2021 06:22

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

Ответить
@basappakarlatthe1006
@basappakarlatthe1006 - 20.02.2022 06:16

Hi Basant can you update this example with new versions of spring boot and elasticsearch...

Ответить
@TheVishnuvnv
@TheVishnuvnv - 04.04.2022 11:52

Great Video, appreciate your efforts! :)

Ответить
@RaviSavarapu
@RaviSavarapu - 07.09.2022 08:00

Nice video, I have one doubt. Why you use net.java.dev.jna

Ответить
@Gautam_kumar_200
@Gautam_kumar_200 - 30.12.2022 19:22

Awesome man

Ответить
@rupeshkhade9140
@rupeshkhade9140 - 06.02.2023 10:05

NodeBuilder is deprecated pls make another video using QueryDSL

Ответить
@codesurmay
@codesurmay - 27.03.2023 08:02

this native search query builder and some methods are deprecated one
so can you please make a another video explaining newer things

Ответить
@vansh1156
@vansh1156 - 02.07.2023 07:19

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

Ответить
@MohitSaini-tv8go
@MohitSaini-tv8go - 21.05.2024 00:30

Awesome Explanation Basant !!!Thanks!!!

Ответить
@yashrao7236
@yashrao7236 - 13.07.2024 12:01

How to manage schema migration in elasticsearch similar to what liquibase does for relational databases?

Ответить