Using a QueryString query
In the previous recipes, we saw several types of query that use text to match the results. The QueryString query is a special type of query that allows you to define complex queries by mixing field rules.
It uses the Lucene query parser in order to parse text to complex queries.
Getting ready
You need a working ElasticSearch cluster and an index populated with the GeoScript chapter_05/populate_query.sh
, available in the code bundle for this book.
How to do it...
We want to retrieve all the documents that match parsedtext
, joe
, or bill
, with a price
between 4
and 6
.
To execute this QueryString query, this is how the code will look:
curl -XPOST 'http://127.0.0.1:9200/test-index/test-type/_search?pretty=true' -d ' { "query": ...
Get ElasticSearch Cookbook - Second Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.