# Best way to match URLs

**URL:** <https://discuss.elastic.co/t/best-way-to-match-urls/15165>\
**Category:** Elasticsearch\
**Created:** [January 9, 2014, 9:15am UTC](https://discuss.elastic.co/t/best-way-to-match-urls/15165 "2014-01-09T09:15:44Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Johan\_Rask](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/johan_rask/32/1132_2.png) [@Johan\_Rask](https://discuss.elastic.co/u/Johan_Rask)\
**Post date:** [January 9, 2014, 9:15am UTC](https://discuss.elastic.co/t/best-way-to-match-urls/15165/1 "2014-01-09T09:15:44Z")

</div>

Hi!

I am using ES together with logstash and we are indexing simple access log  
files.

Our problem is that we want to now the number of image views for a resource  
which is determined by a specific  
REST url:

"GET /resource//image" =\> i.e "GET /resource/abcde/image"

This results in millions of different URL´s that all mean = image view.

Another problem is that there are other "unpredictable" resources under  
/image =\> "GET /resource/abcde/image/"  
so a search like

url:get AND url:resource AND url:image AND - url:\<?\>

does not work since I do not know what to exclude

I was thinking about using regexp for this, performance is not really a  
problem (at least not at the moment), since  
this is mainly for reporting. However, I have not been able to solve it.

If using regex, should the field be analyzed or not\_analyzed? I have tried  
with both using a template but I am still  
unable to get it working.

"url" : {  
"type" : "multi\_field",  
"fields" : {  
"name" : {"type" : "string", "index" : "analyzed" },  
"facet" : {"type" : "string", "index" :  
"not\_analyzed"}  
}  
}

Anyway, any suggestions about how to solve this would be highly appreciated.

Kind regards, Johan

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/01e52f9e-6cc3-4723-ba44-b5a5fdbe9fcc%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/01e52f9e-6cc3-4723-ba44-b5a5fdbe9fcc%40googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 6, 2017, 1:57am UTC](https://discuss.elastic.co/t/best-way-to-match-urls/15165/2 "2017-07-06T01:57:45Z")

</div>


