Using a prefix query/filter
The prefix query/filter is used only when the starting part of a term is known. It allows completing truncated or partial terms.
Getting ready
You need a working ElasticSearch cluster and an index populated with the script available in online code.
How to do it...
For executing a prefix
query/filter, we need to perform the following steps:
We execute a
prefix
query, from command line as follows:curl -XPOST 'http://127.0.0.1:9200/test-index/test-type/_search' -d '{ "query": { "prefix": { "uuid": "333" } } }'
The result, returned by ElasticSearch, is the same as the previous recipe.
If you want use the terms query in a filter, the query should be as follows:
curl -XPOST 'http://127.0.0.1:9200/test-index/test-type/_search' -d '{ "query": { "filtered": { "filter": { "prefix": { "uuid": "333" } }, "query": { "match_all": {...