In the previous recipes we have seen different terms queries (terms, fuzzy, and prefix), another powerful terms query is the regexp
(regular expression) one.
You need a working ElasticSearch cluster and the data populated with the populate script.
For executing the regexp
query/filter, we need to perform the following steps:
We can execute a
regexp
term query from command line as follows:curl -XPOST 'http://127.0.0.1:9200/test-index/test-type/_search' -d '{ "query": { "regexp": { "parsedtext": "j.*", "flags" : "INTERSECTION|COMPLEMENT|EMPTY" } } }'
If scoring is not important, it's better to reformulate the query as a filter in the following way:
curl -XPOST 'http://127.0.0.1:9200/test-index/test-type/_search' -d '{ "query": { "filtered": { "filter": { "regexp": { "parsedtext": "j.*" } }, "query...