# How can I correctly index @screen\_name, #hashtag and url in Japanese text?

**URL:** <https://discuss.elastic.co/t/how-can-i-correctly-index-screen-name-hashtag-and-url-in-japanese-text/147946>\
**Category:** Elasticsearch\
**Created:** [September 10, 2018, 11:13am UTC](https://discuss.elastic.co/t/how-can-i-correctly-index-screen-name-hashtag-and-url-in-japanese-text/147946 "2018-09-10T11:13:33Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![mpyw](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mpyw/32/35006_2.png) [@mpyw](https://discuss.elastic.co/u/mpyw)\
**Post date:** [September 10, 2018, 11:13am UTC](https://discuss.elastic.co/t/how-can-i-correctly-index-screen-name-hashtag-and-url-in-japanese-text/147946/1 "2018-09-10T11:13:33Z")

</div>

# What I need to do

- Use `kuromoji` as a tokenizer and an analyzer for handling Japanese fulltext search
- Recognize tokens that match `/\b@\w{1,30}\b/` (screen\_name)
- Recognize tokens that match [URL Pattern](http://sinya8282.sakura.ne.jp/?p=1064)
- Recognize tokens that match `/\b[#＃][^\p{Zs}]{1,50}(?=\p{Zs}|$)/` (hashtag)
- Highlight matches

How can I achieve all of them at once?

# Current index defintion

Loughly like this:

```
{
  "app": {
    "mappings": {
      "_doc": {
        "dynamic": "false",
        "_source": {
          "enabled": false
        },
        "properties": {
          "type": {
            "type": "keyword"
          },
          "text": {
            "type": "text",
            "store": true,
            "analyzer": "kuromoji_analyzer"
          },
        }
      }
    },
    "settings": {
      "index": {
        "number_of_shards": "1",
        "provided_name": "app",
        "creation_date": "1536550044056",
        "analysis": {
          "analyzer": {
            "kuromoji_analyzer": {
              "filter": [
                "kuromoji_baseform",
                "kuromoji_part_of_speech",
                "cjk_width",
                "stop",
                "ja_stop",
                "kuromoji_stemmer",
                "lowercase"
              ],
              "type": "custom",
              "tokenizer": "kuromoji_tokenizer_search"
            },
          },
          "tokenizer": {
            "kuromoji_tokenizer_search": {
              "mode": "search",
              "type": "kuromoji_tokenizer",
              "discard_punctuation": "true"
            }
          }
        },
        "number_of_replicas": "0",
        "uuid": "AYdPqQSZTjCBJkopeG1_5Q",
        "version": {
          "created": "6030299"
        }
      }
    }
  }
}
```

---

<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:** [October 8, 2018, 11:13am UTC](https://discuss.elastic.co/t/how-can-i-correctly-index-screen-name-hashtag-and-url-in-japanese-text/147946/2 "2018-10-08T11:13:55Z")

</div>

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