# Precise/Regex Search

**URL:** https://discuss.elastic.co/t/precise-regex-search/266141
**Category:** Elastic Search
**Tags:** elastic-app-search
**Created:** [March 3, 2021, 4:38pm UTC](https://discuss.elastic.co/t/precise-regex-search/266141 "2021-03-03T16:38:50Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![pesc](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/pesc/32/82536_2.png) [@pesc](https://discuss.elastic.co/u/pesc)
#### Post date: [March 3, 2021, 4:38pm UTC](https://discuss.elastic.co/t/precise-regex-search/266141/1 "2021-03-03T16:38:50Z")

</div>

Hi

I'm running AppSearch for a research product. I store some IPv6 addresses in it: like

```auto
    2a02:168:2132::1
    2a02:168:2132::2
    2a02:168:be04::42

```

Now the problem is. If I try to search for `2a02:168:2132` it returns `2a02:168:be04::42`too. Any idea? I know it's based on the prefix/... analyser which Elasticsearch uses by default. But is there something I could tweak in my query?

I've tried the following query but without any results...

```auto
{
   "search_fields": {
       "aaaa_record": {}
   },
   "result_fields": {
       "domain": {
           "raw": {}
       },
       "aaaa_record": {
           "raw": {}
       }
   },
   "query": "\"2a02:168:2132.*\""
}

```

---

<div class="post-metadata">

### Author: ![constancecchen](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/constancecchen/32/71762_2.png) [@constancecchen](https://discuss.elastic.co/u/constancecchen)
#### Post date: [March 3, 2021, 8:35pm UTC](https://discuss.elastic.co/t/precise-regex-search/266141/2 "2021-03-03T20:35:29Z")

</div>

Hey hey! You should be able to wrap the `"2a02:168:2132"` query with quotes (so leaving out the `.*` regex).

Before:

 ![without quotes](https://us1.discourse-cdn.com/elastic/original/3X/7/0/7010636637cfed138ed035e82cd37f2eb6a7e8ce.png)

After:

 ![with quotes](https://us1.discourse-cdn.com/elastic/original/3X/e/f/ef68aaaf2a0c01800a072322e2fdd240a8c75f05.png)

Hope that helps! Also for what it's worth, if you're not seeing what I'm seeing, my screenshots are from latest 7.11 Enterprise Search.

---

<div class="post-metadata">

### Author: ![pesc](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/pesc/32/82536_2.png) [@pesc](https://discuss.elastic.co/u/pesc)
#### Post date: [March 4, 2021, 6:27pm UTC](https://discuss.elastic.co/t/precise-regex-search/266141/3 "2021-03-04T18:27:37Z")

</div>

Ahh I see. It's my fault because I've made some own mappings definition (sadly AppSearch doesn't support it)

But why is there no result if I search for `"2a02:168:213"`?

 ![Screenshot 2021-03-04 at 19.27.05](https://us1.discourse-cdn.com/elastic/original/3X/0/4/04d0c593fc0ee9cb512df70a07e039ef4f333efb.png)

---

<div class="post-metadata">

### Author: ![pesc](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/pesc/32/82536_2.png) [@pesc](https://discuss.elastic.co/u/pesc)
#### Post date: [March 4, 2021, 6:35pm UTC](https://discuss.elastic.co/t/precise-regex-search/266141/4 "2021-03-04T18:35:38Z")

</div>

Is it because of the "iq\_text\_base"?

```auto
{
  "analyzer": "iq_text_base",
  "text": "2a02:168:2132::2"
}

```

```auto
{
    "tokens": [
        {
            "token": "2a02",
            "start_offset": 0,
            "end_offset": 4,
            "type": "<ALPHANUM>",
            "position": 0
        },
        {
            "token": "168",
            "start_offset": 5,
            "end_offset": 8,
            "type": "<NUM>",
            "position": 1
        },
        {
            "token": "2132",
            "start_offset": 9,
            "end_offset": 13,
            "type": "<NUM>",
            "position": 2
        },
        {
            "token": "2",
            "start_offset": 15,
            "end_offset": 16,
            "type": "<NUM>",
            "position": 3
        }
    ]
}

```

---

<div class="post-metadata">

### Author: ![constancecchen](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/constancecchen/32/71762_2.png) [@constancecchen](https://discuss.elastic.co/u/constancecchen)
#### Post date: [March 4, 2021, 6:50pm UTC](https://discuss.elastic.co/t/precise-regex-search/266141/5 "2021-03-04T18:50:26Z")

</div>

Ahh, I'm seeing the same thing as you with no results for `"2a02:168:213"`. As to why, I'm probably the worst person to be asking this question of because I'm not as familiar with our inner Elasticsearch workings as my coworkers 😬 @Aurelien_Foucret1 can I tag you in on this once since you're working on our new precision tuners?

Pascal, it's possible we may not currently have the option/customization to get you the exact search response you want right now, but we're working on a way to let customers fine-tune precision vs. recall and configure more (but as a heads up, not all) of Elasticsearch's query options.

---

<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: [April 1, 2021, 6:51pm UTC](https://discuss.elastic.co/t/precise-regex-search/266141/6 "2021-04-01T18:51:19Z")

</div>

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