# How can I do a one-to-one search in the title field?

**URL:** <https://discuss.elastic.co/t/how-can-i-do-a-one-to-one-search-in-the-title-field/293523>\
**Category:** Elasticsearch\
**Created:** [January 5, 2022, 10:46am UTC](https://discuss.elastic.co/t/how-can-i-do-a-one-to-one-search-in-the-title-field/293523 "2022-01-05T10:46:03Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![Busra\_Duygu](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/busra_duygu/32/90462_2.png) [@Busra\_Duygu](https://discuss.elastic.co/u/Busra_Duygu)\
**Post date:** [January 5, 2022, 10:46am UTC](https://discuss.elastic.co/t/how-can-i-do-a-one-to-one-search-in-the-title-field/293523/1 "2022-01-05T10:46:03Z")

</div>

Hello friends, I have a problem, I would be very happy if you could help. I want it to return exactly the string I want in a query using Wilcard, but it doesn't work. I have a document and document's title:

> "Title" : "BREMAX SA"

The document id of this document is:

> "\_id" : "rMEMC3oBChFNLIc8INEm"

When I search using match with id, the result is returned successfully, but when I search with title field, no results are returned. That's why I'm using wildcard, but still no results.

**when i search using document id:**

```auto
GET my_index_name/_search
{
  "query": {
    "match": {
      "_id": "rMEMC3oBChFNLIc8INEm"
    }
  }
}

```

**result returns successfully:**

```auto
"hits" : [
      {
        "_index" : "my_index_name",
        "_type" : "_doc",
        "_id" : "rMEMC3oBChFNLIc8INEm",
        "_score" : 1.0,
        "_source" : {
          "CreateTime" : "2021-06-14T18:03:01.9387582+03:00",
          "Title" : "BREMAX SA",
          "OriginCountryId" : 24972,
          "CreatedBy" : 1,
          "IsActivated" : false,
          "IsCancelled" : false,
          "IsMembershipTypeBought" : false
        }
      }
    ]

```

**When I search with wildcard or match using the title field:**

```auto
GET my_index_name/_search
{
  "query": {
    "wildcard": {
      "Title": {
        "value": "*BREMAX SA*",
        "case_insensitive": true
      }
    }
  }
}

```

**no results found:**  
`"hits" : []`  
I would be very grateful if you could help 😊

---

<div class="post-metadata">

**Author:** ![can.ozdemir](https://avatars.discourse-cdn.com/v4/letter/c/898d66/32.png) [@can.ozdemir](https://discuss.elastic.co/u/can.ozdemir)\
**Post date:** [January 5, 2022, 11:04am UTC](https://discuss.elastic.co/t/how-can-i-do-a-one-to-one-search-in-the-title-field/293523/2 "2022-01-05T11:04:43Z")

</div>

Hi there,

Elasticsearch uses tokenizers for fields, when you index "BREMAX SA" Elasticsearch uses standard analyzer which tokenize field content using non-letter and space.

[analyzers](https://www.elastic.co/guide/en/elasticsearch/reference/current/analysis-tokenizers.html)

So when you index BREMAX SA the inverted index, where the full-text search happens, there are two separate tokens created, BREMAX and SA, because there are no "BREMAX SA" token you cannot wildcard match it using \* before and after.

In your current state what you can do is search for "_BREMAX_" or "_SA_", which in its own is a very bad idea Elasticsearch specifically mentions not to start and end with wildcard symbols.

If you want to be able to search for "BREMAX SA" with wildcards you need keyword tokenizer in your analyzer, which will keep the string inside the field whole.

edit:

or you can use a multifield keyword like this;

```auto
GET test/_search
{
  "query": {
    "wildcard": {
      "Title.keyword": {
        "value": "*BREMAX SA*",
        "case_insensitive": true
      }
    }
  }
}

```

but this approach is not what you are looking for in my opinion.

Best regards.

---

<div class="post-metadata">

**Author:** ![Busra\_Duygu](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/busra_duygu/32/90462_2.png) [@Busra\_Duygu](https://discuss.elastic.co/u/Busra_Duygu)\
**Post date:** [January 5, 2022, 11:24am UTC](https://discuss.elastic.co/t/how-can-i-do-a-one-to-one-search-in-the-title-field/293523/3 "2022-01-05T11:24:23Z")

</div>

When I tried with **.keyword** it failed again, but when I tried with **.raw** it succeeded..

```auto
GET my_index_name/_search
{
  "query": {
   "wildcard": {
     "Title.raw": {
       "value": "*BREMAX SA*",
       "case_insensitive": true
     }
   }
  }
}

```

@can.ozdemir thank you so much for helping 🤗

---

<div class="post-metadata">

**Author:** ![Busra\_Duygu](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/busra_duygu/32/90462_2.png) [@Busra\_Duygu](https://discuss.elastic.co/u/Busra_Duygu)\
**Post date:** [January 6, 2022, 12:00pm UTC](https://discuss.elastic.co/t/how-can-i-do-a-one-to-one-search-in-the-title-field/293523/4 "2022-01-06T12:00:30Z")

</div>

hello @can.ozdemir . I have a problem again. I have a field whose type is text under two fields whose type is nesten. I want to search using wildcard on this field. However, this is not possible and no results are returned.

```auto
"Field1" : {
    "type" : "nested",
    "properties" : {
        "Field2" : {
          "type" : "nested",
          "properties" : { 
               "Field3" : { 
                  "type" : "text" 
                } 
          }
        }
    }
}

```

**When I run (.raw or .keyword) the following query, no results are found:**

```auto
GET my_index_name/_search
{
  "query": {
    "nested": {
      "path": "Field1.Field2",
      "query": {
        "bool": {
          "must": [
            {"wildcard": {
              "Field1.Field2.Field3.raw": {
                "value": "*FYX-F*",
                "case_insensitive":true
              }
            }
            }
          ]
        }    
      }
    }
  }
}

```

What is your opinion I can do ?

---

<div class="post-metadata">

**Author:** ![can.ozdemir](https://avatars.discourse-cdn.com/v4/letter/c/898d66/32.png) [@can.ozdemir](https://discuss.elastic.co/u/can.ozdemir)\
**Post date:** [January 6, 2022, 12:07pm UTC](https://discuss.elastic.co/t/how-can-i-do-a-one-to-one-search-in-the-title-field/293523/5 "2022-01-06T12:07:46Z")

</div>

Hi,

Field3 doesn't have a raw field type, it only has text;

```auto
"properties" : { 
               "Field3" : { 
                  "type" : "text" 
                } 
          }

```

You do not need to put .raw at the end there, you are using the text field.

---

<div class="post-metadata">

**Author:** ![Busra\_Duygu](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/busra_duygu/32/90462_2.png) [@Busra\_Duygu](https://discuss.elastic.co/u/Busra_Duygu)\
**Post date:** [January 6, 2022, 12:10pm UTC](https://discuss.elastic.co/t/how-can-i-do-a-one-to-one-search-in-the-title-field/293523/6 "2022-01-06T12:10:14Z")

</div>

I tried without putting it but it doesn't work.

---

<div class="post-metadata">

**Author:** ![can.ozdemir](https://avatars.discourse-cdn.com/v4/letter/c/898d66/32.png) [@can.ozdemir](https://discuss.elastic.co/u/can.ozdemir)\
**Post date:** [January 6, 2022, 12:32pm UTC](https://discuss.elastic.co/t/how-can-i-do-a-one-to-one-search-in-the-title-field/293523/7 "2022-01-06T12:32:01Z")

</div>

Yes it is not going to work since "text" fields are analyzed by standard analyzer. I explained this on the first question you asked. "non-letters and spaces" standard analyzer will create two tokens again FYX and F so you need to change your mapping and add a keyword field to "Field3" or you should change your tokenizer to keyword to keep the field whole.

---

<div class="post-metadata">

**Author:** ![Busra\_Duygu](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/busra_duygu/32/90462_2.png) [@Busra\_Duygu](https://discuss.elastic.co/u/Busra_Duygu)\
**Post date:** [January 6, 2022, 12:50pm UTC](https://discuss.elastic.co/t/how-can-i-do-a-one-to-one-search-in-the-title-field/293523/8 "2022-01-06T12:50:14Z")

</div>

Do I need to reindex to do this?

---

<div class="post-metadata">

**Author:** ![can.ozdemir](https://avatars.discourse-cdn.com/v4/letter/c/898d66/32.png) [@can.ozdemir](https://discuss.elastic.co/u/can.ozdemir)\
**Post date:** [January 6, 2022, 12:54pm UTC](https://discuss.elastic.co/t/how-can-i-do-a-one-to-one-search-in-the-title-field/293523/9 "2022-01-06T12:54:20Z")

</div>

It depends on your current mappings, just try to update your current mapping and add a fields property to your Field3 use the link below;

[https://www.elastic.co/guide/en/elasticsearch/reference/current/multi-fields.html](https://www.elastic.co/guide/en/elasticsearch/reference/current/multi-fields.html)

when you are updating an index use the \_mapping endpoint;

```auto
PUT your-index-name/_mapping

```

ps: this is getting derailed please publish your further questions about other topics on other questions.

---

<div class="post-metadata">

**Author:** ![Busra\_Duygu](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/busra_duygu/32/90462_2.png) [@Busra\_Duygu](https://discuss.elastic.co/u/Busra_Duygu)\
**Post date:** [January 6, 2022, 1:10pm UTC](https://discuss.elastic.co/t/how-can-i-do-a-one-to-one-search-in-the-title-field/293523/10 "2022-01-06T13:10:58Z")

</div>

Okay, thank you so much for all your help.

---

<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 3, 2022, 1:11pm UTC](https://discuss.elastic.co/t/how-can-i-do-a-one-to-one-search-in-the-title-field/293523/11 "2022-02-03T13:11:08Z")

</div>

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