# Limit search return to exact match for URL

**URL:** https://discuss.elastic.co/t/limit-search-return-to-exact-match-for-url/165670
**Category:** Elasticsearch
**Created:** [January 24, 2019, 9:36pm UTC](https://discuss.elastic.co/t/limit-search-return-to-exact-match-for-url/165670 "2019-01-24T21:36:32Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![MarkStewart](https://avatars.discourse-cdn.com/v4/letter/m/8e7dd6/32.png) [@MarkStewart](https://discuss.elastic.co/u/MarkStewart)
#### Post date: [January 24, 2019, 9:36pm UTC](https://discuss.elastic.co/t/limit-search-return-to-exact-match-for-url/165670/1 "2019-01-24T21:36:32Z")

</div>

I have an index I am searching that has a field under \_source called request\_path.

This field has some similar URLs saved in over 38,000 documents.  
in the format (under \_source)  
"request\_path": "/v1/api-portal/teams/",  
"request\_path": "/v1/api-portal/teams/fbf167c0-67fd-4239-8437-62b48bd25439",  
"request\_path": "/v1/api-portal/teams/a3f73bda-2c0b-4e4c-aa08-e3351c13727c",

I tried several variations of match\_phrase to just return the 1st example "/v1/api-portal/teams/" and not return any of the variations like the 2nd and 3rd line above. Filtering is not possible as the GUID changes and there are many variations.  
I just want to see documents with "/v1/api-portal/teams/" but NOT any with extra GUID like "/v1/api-portal/teams/fbf167c0-67fd-4239-8437-62b48bd25439",

The query I was using is close to giving me what I need as it gets 95% correct but it still finds documents with a score high enough to get the GUID in the answer.

What i got closest with.

GET /portal.api\*/\_search?size=10000  
{  
"query": {  
"match\_phrase" : {  
"request\_path" : "/v1/api-portal/teams"  
}  
}  
}

Any hints to clean out the request\_path items with the GUID and only return the portion w/o the GUID? I just need documents with this to return. "request\_path": "/v1/api-portal/teams" and nothing else

Thanks in advance.  
(ps I have been away from ELK for a period since around the 2.5.4 release era and am now back using it at a new job running on Version 5.5)

---

<div class="post-metadata">

### Author: ![MarkStewart](https://avatars.discourse-cdn.com/v4/letter/m/8e7dd6/32.png) [@MarkStewart](https://discuss.elastic.co/u/MarkStewart)
#### Post date: [January 24, 2019, 10:05pm UTC](https://discuss.elastic.co/t/limit-search-return-to-exact-match-for-url/165670/2 "2019-01-24T22:05:13Z")

</div>

Mapping for the request\_path field is as follows  
"request\_path": {  
"type": "text",  
"fields": {  
"keyword": {  
"type": "keyword",  
"ignore\_above": 256  
}

---

<div class="post-metadata">

### Author: ![abdon](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/abdon/32/9195_2.png) [@abdon](https://discuss.elastic.co/u/abdon)
#### Post date: [January 24, 2019, 11:31pm UTC](https://discuss.elastic.co/t/limit-search-return-to-exact-match-for-url/165670/3 "2019-01-24T23:31:28Z")

</div>

Try querying the `request_path.keyword` multifield with a regular match query:

```auto
GET /portal.api*/_search?size=10000
{
  "query": {
    "match": {
      "request_path.keyword": "/v1/api-portal/teams"
    }
  }
}

```

The keyword multifield is not analyzed, and allows you to search for exact matches.

If you're coming from 2.x, you may remember the `.raw` multifields. Those offered the same functionality back in 2.x

---

<div class="post-metadata">

### Author: ![MarkStewart](https://avatars.discourse-cdn.com/v4/letter/m/8e7dd6/32.png) [@MarkStewart](https://discuss.elastic.co/u/MarkStewart)
#### Post date: [January 25, 2019, 1:22pm UTC](https://discuss.elastic.co/t/limit-search-return-to-exact-match-for-url/165670/4 "2019-01-25T13:22:04Z")

</div>

Abdon,  
Thank you very much. This is what I was looking for. Yes I do remember the .raw data and was what I was looking for but couldn't seem to find what it changed to or how to work around it not being there.

Thanks again.

Mark

---

<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: [February 22, 2019, 1:22pm UTC](https://discuss.elastic.co/t/limit-search-return-to-exact-match-for-url/165670/5 "2019-02-22T13:22:05Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
