February 2019
Intermediate to advanced
442 pages
11h 46m
English
Since this is a blog application, search is an obvious feature. We will allow a user to search the blogs by matching the search text with blog title and body. We can search the documents by passing /_search at the end of the URL. Elasticsearch provides a Boolean query to search the data based on various conditions.
In our case, the search text should be matched with either title or body or both. It can be achieved through a Boolean search query as follows:
GET blog/blog/_search{ "query": { "bool": { "should": [ { "match": { "title": "java" }}, { "match": { "body": "java" }} ] } }}
The should criteria is equivalent to the OR condition. Elasticsearch provides the must criteria, in case if you want to search with the AND ...