How to combine queries with bool query - Spring Data Elasticsearch - Part 6

preview_player
Показать описание
In this tutorial series we take a look at Elasticsearch and see how we can use it together with Spring Boot. To make things easier for use we use awesome Spring Data Elasticsearch. For all of those who are not familiar with it, Elasticsearch is a distributed, free and open search and analytics engine for all types of data, including textual, numerical, geospatial, structured, and unstructured. Elasticsearch is built on Apache Lucene and was first released in 2010 by Elasticsearch N.V. (now known as Elastic). Known for its simple REST APIs, distributed nature, speed, and scalability, Elasticsearch is the central component of the Elastic Stack, a set of free and open tools for data ingestion, enrichment, storage, analysis, and visualization. Commonly referred to as the ELK Stack (after Elasticsearch, Logstash, and Kibana), the Elastic Stack now includes a rich collection of lightweight shipping agents known as Beats for sending data to Elasticsearch.

In this video we take a look how we can use Bool Query to combine multiple other queries.

Boolean query:
A query that matches documents matching boolean combinations of other queries. The bool query maps to Lucene BooleanQuery. It is built using one or more boolean clauses, each clause with a typed occurrence. The occurrence types are:

must - the clause (query) must appear in matching documents and will contribute to the score.

filter - the clause (query) must appear in matching documents. However unlike must the score of the query will be ignored. Filter clauses are executed in filter context, meaning that scoring is ignored and clauses are considered for caching.

should - the clause (query) should appear in the matching document.

must_not - the clause (query) must not appear in the matching documents. Clauses are executed in filter context meaning that scoring is ignored and clauses are considered for caching. Because scoring is ignored, a score of 0 for all documents is returned.

Java API:

Source code:

This videos commit:

Experience the search:

#java #springboot #elasticsearch
Рекомендации по теме
Комментарии
Автор

Great experience it helps to understand elastic search thanks a lot for help.

editor
Автор

Please make some videos on aggregations also btw thanks amazing tutorials

DeepNarrow
Автор

hi why you are using final as your parameter ? for example final SearchRequest, we can remove final keyword?

chenpeter
Автор

hi i want to ask why you can order with ASC even though you didnt assign sortBy in the body request ? cause that not going through to if (dto.getSortBy() != null) {

genprimabiocakti
join shbcf.ru