# Searching for "foo" should also find occurrence of "foo.bar"

**URL:** <https://discuss.elastic.co/t/searching-for-foo-should-also-find-occurrence-of-foo-bar/1546>\
**Category:** Elasticsearch\
**Created:** [May 29, 2015, 8:54am UTC](https://discuss.elastic.co/t/searching-for-foo-should-also-find-occurrence-of-foo-bar/1546 "2015-05-29T08:54:36Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![marian](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/marian/32/442_2.png) [@marian](https://discuss.elastic.co/u/marian)\
**Post date:** [May 29, 2015, 8:54am UTC](https://discuss.elastic.co/t/searching-for-foo-should-also-find-occurrence-of-foo-bar/1546/1 "2015-05-29T08:54:36Z")

</div>

We have ElasticSearch 1.5 set up with a very simple mapping to perform full text search in [our docs](https://docs.giantswarm.io/). When searching for "swarmvars" we get no hits, although "swarmvars.json" appears in documents.

The field "text" is used as a catch-all field for all searchable content (title, document body, keywords). Here is the mapping:

```
"properties": {
  ...,
  "text": {
    "type": "string",
    "store": true,
    "index": "analyzed",
    "term_vector": "with_positions_offsets",
    "analyzer": "english",
  }
}

```

When using the "english" analyzer on the text "Text containing swarmvars.json and more", the result are these tokens:

```
text
contain
swarmvars.json
more

```

Having the token "swarmvars.json" is fine. What I need are two additional tokens "swarmvars" and "json". How can I achieve that?

I was looking into creating a custom tokenizer, but I was unable to get it to work (errors when applying the settings) and also I was unable to find an example, no matter how I searched.

Thanks!

---

<div class="post-metadata">

**Author:** ![Jason\_Wee](https://avatars.discourse-cdn.com/v4/letter/j/7ea924/32.png) [@Jason\_Wee](https://discuss.elastic.co/u/Jason_Wee)\
**Post date:** [May 30, 2015, 9:31am UTC](https://discuss.elastic.co/t/searching-for-foo-should-also-find-occurrence-of-foo-bar/1546/2 "2015-05-30T09:31:42Z")

</div>

simple analyzer shoudl be able to split that into token? underneath is use lowercase tokenizer [Lowercase tokenizer | Elasticsearch Guide [8.11] | Elastic](https://www.elastic.co/guide/en/elasticsearch/reference/current/analysis-lowercase-tokenizer.html)

> It divides text at non-letters and converts them to lower case.

```
$ curl -XGET 'localhost:9200/my_index/_analyze?analyzer=simple&pretty&explain' -d 'Text containing swarmvars.json and more'
{
  "tokens" : [ {
    "token" : "text",
    "start_offset" : 0,
    "end_offset" : 4,
    "type" : "word",
    "position" : 1
  }, {
    "token" : "containing",
    "start_offset" : 5,
    "end_offset" : 15,
    "type" : "word",
    "position" : 2
  }, {
    "token" : "swarmvars",
    "start_offset" : 16,
    "end_offset" : 25,
    "type" : "word",
    "position" : 3
  }, {
    "token" : "json",
    "start_offset" : 26,
    "end_offset" : 30,
    "type" : "word",
    "position" : 4
  }, {
    "token" : "and",
    "start_offset" : 31,
    "end_offset" : 34,
    "type" : "word",
    "position" : 5
  }, {
    "token" : "more",
    "start_offset" : 35,
    "end_offset" : 39,
    "type" : "word",
    "position" : 6
  } ]
}

```

hth

jason

---

<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 6, 2017, 12:10am UTC](https://discuss.elastic.co/t/searching-for-foo-should-also-find-occurrence-of-foo-bar/1546/3 "2017-07-06T00:10:38Z")

</div>


