D
D
Denis Bondarenko2019-12-13 11:17:48
elasticsearch
Denis Bondarenko, 2019-12-13 11:17:48

How can I efficiently search for URIs that match a pattern using Elastic?

It is necessary to look for records whose value data.request.uriwould match the pattern /plans/:id/order, where :idis a variable value (24-digit ID from MongoDB, for example).
Having tried different options (regulars, Query string), I did not find anything more effective than stupidly finding it through match:

{
    "query": {
    	"bool" : {
    		"must": [
    			{
      		"range" : {
                "@timestamp" : {
                    "gte" : "2019-06-11T00:00:00",
                    "lt" : "now"
              		}
          		}
    			},
    			{
    				"match" : {
          			"data.request.method" : {
          				"query" : "PUT"
          			}
          		}
    			},
    			{
    				"match" : {
          			"data.request.uri" : {
          				"query" : "plans order"
          			}
          		}
    			}
      ]
    		}
  }
}

But this method looks, to put it mildly, clumsy.
What is the most appropriate way to find records that match a pattern?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question