# URL with special characters when searched not working in ElasticSearch 5.2.2

**URL:** <https://discuss.elastic.co/t/url-with-special-characters-when-searched-not-working-in-elasticsearch-5-2-2/96552>\
**Category:** Elasticsearch\
**Created:** [August 10, 2017, 6:05am UTC](https://discuss.elastic.co/t/url-with-special-characters-when-searched-not-working-in-elasticsearch-5-2-2/96552 "2017-08-10T06:05:45Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![abhisekdg](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/abhisekdg/32/20997_2.png) [@abhisekdg](https://discuss.elastic.co/u/abhisekdg)\
**Post date:** [August 10, 2017, 6:05am UTC](https://discuss.elastic.co/t/url-with-special-characters-when-searched-not-working-in-elasticsearch-5-2-2/96552/1 "2017-08-10T06:05:46Z")

</div>

I am not able to search URL's which contains special characters like [http://example.sample.com/guide/Analyzers\_Terms\_and\_Analysis\_(ABC)\_Guide](http://example.sample.com/guide/Analyzers_Terms_and_Analysis_%28ABC%29_Guide)

Suppose I have indexed 4 `noteText`

1. `http://example.sample.com/guide/Analyzers_Terms_and_Analysis_%28ABC%29_Guide`

2. `example`

3. `Terms`

4. `Analysis`

Expected Result - When I search with full URL option (1) it should output me the exact result of URL only and not with partial search with other indexed values like `example`, `Terms`, `Analysis`.

Index Settings -

```auto
PUT my_index
{
  "settings": {
    "index": {
      "analysis": {
        "filter": {
          "my_ngram": {
            "type": "nGram",
            "min_gram": 1,
            "max_gram": 50
          }
        },
        "char_filter": {
          "whitespace_mapping": {
            "mappings": [
              "\\u00A0=>\\u0020"
            ],
            "type": "mapping"
          }
        },
        "analyzer": {
          "default": {
            "type": "custom",
            "char_filter": [
              "whitespace_mapping"
            ],
            "filter": [
              "lowercase",
              "asciifolding",
              "stop",
              "my_ngram",
              "kstem"
            ],
            "tokenizer": "whitespace"
          },
          "default_search": {
            "type": "custom",
            "char_filter": [
              "whitespace_mapping"
            ],
            "filter": [
              "lowercase",
              "asciifolding",
              "kstem"
            ],
            "tokenizer": "whitespace"
          },
          "match_phrase": {
            "type": "custom",
            "char_filter": [
              "whitespace_mapping"
            ],
            "filter": [
              "lowercase"
            ],
            "tokenizer": "whitespace"
          },
          "match_phrase_search": {
            "type": "custom",
            "char_filter": [
              "whitespace_mapping"
            ],
            "filter": [
              "lowercase",
              "stop"
            ],
            "tokenizer": "whitespace"
          }
        }
      }
    }
  }
}

```

Mapping -

```auto

PUT my_index/_mapping/notes
{
    "properties": {
      "userId": {
        "type": "long"
      },
      "noteText": {
        "analyzer": "match_phrase",
        "term_vector": "with_positions_offsets",
        "type": "text",
        "fields": {
          "ngrammed": {
            "term_vector": "with_positions_offsets",
            "type": "text"
          }
        }
      }
    }
}

```

Search Query -

```auto
POST /my_index/_search 
{
  
  "query": {
    "bool": {
      "must": [
        {
          "constant_score": {
            "query": {
              "query_string": {
                "query": "http://example.sample.com/guide/Analyzers_Terms_and_Analysis_%28ABC%29_Guide",
                "fields": [
                  "noteText.ngrammed"
                ],
                "analyzer": "match_phrase_search"
              }
            },
            "boost": 5
          }
        },
        {
          "query_string": {
            "query": "http://example.sample.com/guide/Analyzers_Terms_and_Analysis_%28ABC%29_Guide",
            "fields": [
              "noteText.ngrammed"
            ]
          }
        }
      ]
    }
  }
}

```

---

<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:** [August 10, 2017, 7:12am UTC](https://discuss.elastic.co/t/url-with-special-characters-when-searched-not-working-in-elasticsearch-5-2-2/96552/2 "2017-08-10T07:12:15Z")

</div>

Please don't post pictures but code.

And format it using `</>` icon as explained in [this guide](https://discuss.elastic.co/t/about-the-elasticsearch-category/21). It will make your post more readable.

Or use markdown style like:

````
```
CODE
```
````

---

<div class="post-metadata">

**Author:** ![abhisekdg](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/abhisekdg/32/20997_2.png) [@abhisekdg](https://discuss.elastic.co/u/abhisekdg)\
**Post date:** [August 10, 2017, 8:15am UTC](https://discuss.elastic.co/t/url-with-special-characters-when-searched-not-working-in-elasticsearch-5-2-2/96552/3 "2017-08-10T08:15:43Z")

</div>

Done changed pictures to code. Thanks !!!

---

<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:** [September 7, 2017, 8:15am UTC](https://discuss.elastic.co/t/url-with-special-characters-when-searched-not-working-in-elasticsearch-5-2-2/96552/4 "2017-09-07T08:15:46Z")

</div>

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