# How do I search words seperated by \_ and . in ElasticSearch?

**URL:** <https://discuss.elastic.co/t/how-do-i-search-words-seperated-by---and-in-elasticsearch/42468>\
**Category:** Elasticsearch\
**Created:** [February 23, 2016, 8:20am UTC](https://discuss.elastic.co/t/how-do-i-search-words-seperated-by---and-in-elasticsearch/42468 "2016-02-23T08:20:21Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![stevebissett](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/stevebissett/32/7983_2.png) [@stevebissett](https://discuss.elastic.co/u/stevebissett)\
**Post date:** [February 23, 2016, 8:20am UTC](https://discuss.elastic.co/t/how-do-i-search-words-seperated-by---and-in-elasticsearch/42468/1 "2016-02-23T08:20:21Z")

</div>

I am new to ElasticSearch and I am very happy with the speed at the moment. I still have one requirement that I haven't been able to achieve.

ElasticSearch seems to split the following text when doing indexing:

```
"bmw.co.uk"
"apple_macbook_pro"

```

I am searching in Ruby like this using the ElasticSearch gem:

```
result = client.search index: 'elasticsearch_dev',
                  body: {
                      query: {
                          "bool" => {
                            "must" => {"match" => {"search_text" => {"query" => "bmw", "operator" => "and"}}},
                            "must_not" => {"match" => {"search_text" => {"query" => "", "operator" => "or"}}}
                          }
                      },
                  }

```

**What I'm trying to achieve:**

When I search for `bmw` or `bmw.co`, I want records with `bmw.co.uk` to match.

When I search for `acboo` or `apple`, I want records with `apple_macbook_pro` to match.

How do I go about achieving this?

_Additional Info_

I have looked at this site, which is along the lines of what I am looking to do, but not quite:

[http://www.fullscale.co/blog/2013/03/04/preserving\_specific\_characters\_during\_tokenizing\_in\_elasticsearch.html](http://www.fullscale.co/blog/2013/03/04/preserving_specific_characters_during_tokenizing_in_elasticsearch.html).

If I have the URL:

```
uk-on-sale.com

```

I want this to be tokenized as:

```
[uk, on, sale, com, uk-on, on-sale, uk-on-sale.com, on-sale.com, sale.com, .com]
```

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [February 24, 2016, 6:53pm UTC](https://discuss.elastic.co/t/how-do-i-search-words-seperated-by---and-in-elasticsearch/42468/2 "2016-02-24T18:53:19Z")

</div>

This is all about analysis with the various outputs that you want.  
You may want to read through this chapter of the definitive guide to give you some context - [https://www.elastic.co/guide/en/elasticsearch/guide/master/languages.html](https://www.elastic.co/guide/en/elasticsearch/guide/master/languages.html)

---

<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:** [July 5, 2017, 11:13pm UTC](https://discuss.elastic.co/t/how-do-i-search-words-seperated-by---and-in-elasticsearch/42468/3 "2017-07-05T23:13:52Z")

</div>


