# Having hard time matching queries with forward slash & ampersand

**URL:** https://discuss.elastic.co/t/having-hard-time-matching-queries-with-forward-slash-ampersand/279303
**Category:** Elasticsearch
**Created:** [July 21, 2021, 6:26pm UTC](https://discuss.elastic.co/t/having-hard-time-matching-queries-with-forward-slash-ampersand/279303 "2021-07-21T18:26:20Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Webtrend\_Inc](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/webtrend_inc/32/70034_2.png) [@Webtrend\_Inc](https://discuss.elastic.co/u/Webtrend_Inc)
#### Post date: [July 21, 2021, 6:26pm UTC](https://discuss.elastic.co/t/having-hard-time-matching-queries-with-forward-slash-ampersand/279303/1 "2021-07-21T18:26:20Z")

</div>

I want to identify urls like this from our elastic index `http://example.com/?a=1&c=1&s1=1` where the domain name can change. So, I have to rely on matching using the query pattern.

In a nutshell, something like this `*/?a=*&c=*` would be my desired query

From what I have read, the field should be mapped as a keyword rather than a string because tokenization will ignore some characters.  
However, after mapping this field as a keyword, the queries are partially working but I cannot use any search expressions which has `/` or `&` sign. Here is my query

```auto
GET my_index/_search
{
  "query": {
      "bool": {
        "must": [
          {
            "nested" : {
            "path" : "chain",
            "score_mode" : "avg",
            "query": {
              "query_string" : {
                "query" : "*\\?a=*",
                "fields": ["chain.query"]
              }
            }
            }
          }
        ]
      }
    }
}

```

The above query works but if I try to include slash or ampersand (`*\\?a=*\\&c=*`) it does not work. I get 0 results despite having such matching content in the elastic doc.

---

<div class="post-metadata">

### Author: ![Webtrend\_Inc](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/webtrend_inc/32/70034_2.png) [@Webtrend\_Inc](https://discuss.elastic.co/u/Webtrend_Inc)
#### Post date: [July 21, 2021, 7:05pm UTC](https://discuss.elastic.co/t/having-hard-time-matching-queries-with-forward-slash-ampersand/279303/2 "2021-07-21T19:05:10Z")

</div>

Sorry, I was querying the incorrect field that is why I was having this issue. It is solved now. You can ignore this question

---

<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: [August 18, 2021, 7:06pm UTC](https://discuss.elastic.co/t/having-hard-time-matching-queries-with-forward-slash-ampersand/279303/3 "2021-08-18T19:06:03Z")

</div>

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