# Index and Search URL

**URL:** <https://discuss.elastic.co/t/index-and-search-url/160734>\
**Category:** Elasticsearch\
**Created:** [December 13, 2018, 12:18pm UTC](https://discuss.elastic.co/t/index-and-search-url/160734 "2018-12-13T12:18:32Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![h1fra](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/h1fra/32/38789_2.png) [@h1fra](https://discuss.elastic.co/u/h1fra)\
**Post date:** [December 13, 2018, 12:18pm UTC](https://discuss.elastic.co/t/index-and-search-url/160734/1 "2018-12-13T12:18:32Z")

</div>

Hello,

I've searched a lot around this forum and google but I didn't find a proper way to index URL that would also allow partial match.  
My use case is, I have documents that contains fully qualified URL (hostname + path + query string), I want to them to be searchable, either exact match or partial match.  
I've put a `keyword` mapping right now because I don't want my URL to split in multiple keyword.

```json
# Mapping
{
  "mappings": {
    "properties": {
      "url": {
        "type": "keyword"
      }
    }
  }
}

```

```json
# Document example
{
  "_source": {
    "url": "https://discuss.elastic.co/t/indexing-and-searching-urls-with-dashes/6977?foo=bar"
  }
}

```

Let say I have this URL: `https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-wildcard-query.html?pid=1234`.  
I want to find it when I type:

- `https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-wildcard-query.html?pid=1234`
- `www.elastic.co`
- `elasticsearch/reference/current`
- `pid`
- [anything really ...]

The problem I have, is that ngram would be too big to generate (I think), wildcard is working but I suppose it's slow.  
Is there a good solution to this ?

Thanks,

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [December 13, 2018, 12:38pm UTC](https://discuss.elastic.co/t/index-and-search-url/160734/2 "2018-12-13T12:38:59Z")

</div>

May be using a path tokenizer would help?

---

<div class="post-metadata">

**Author:** ![h1fra](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/h1fra/32/38789_2.png) [@h1fra](https://discuss.elastic.co/u/h1fra)\
**Post date:** [January 4, 2019, 2:22pm UTC](https://discuss.elastic.co/t/index-and-search-url/160734/3 "2019-01-04T14:22:54Z")

</div>

Hey,

I thought about that but that would only work for querying/agg a specific part of the path (Not sure)  
I don't think it will work when searching for =\> `elastic.co/foo?bar`

`Wildcard` is returning results in a few seconds for 8millions rows and once in the cache a few hundred milliseconds. The machine is not really big so I guess I could throw more CPU/memory but I'm sad that there is not good way to do that, specially considering a lot of people are using ELK to store webserver log.

---

<div class="post-metadata">

**Author:** ![softwaredoug](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/softwaredoug/32/22681_2.png) [@softwaredoug](https://discuss.elastic.co/u/softwaredoug)\
**Post date:** [January 4, 2019, 2:46pm UTC](https://discuss.elastic.co/t/index-and-search-url/160734/4 "2019-01-04T14:46:19Z")

</div>

At some point I think it’s just simpler to preparse this into different fields. Each component of the URL probably has different prioritizarion in your ranking. So I would deconstruct the URL at index and query time and search each individual attribute separately as different fields.

---

<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 1, 2019, 2:46pm UTC](https://discuss.elastic.co/t/index-and-search-url/160734/5 "2019-02-01T14:46:24Z")

</div>

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