# Stop token filter how to set whitespace char as stop word in stopwords\_path config file

**URL:** <https://discuss.elastic.co/t/stop-token-filter-how-to-set-whitespace-char-as-stop-word-in-stopwords-path-config-file/282429>\
**Category:** Elasticsearch\
**Created:** [August 25, 2021, 2:59am UTC](https://discuss.elastic.co/t/stop-token-filter-how-to-set-whitespace-char-as-stop-word-in-stopwords-path-config-file/282429 "2021-08-25T02:59:42Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![chenchuangc](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/chenchuangc/32/40017_2.png) [@chenchuangc](https://discuss.elastic.co/u/chenchuangc)\
**Post date:** [August 25, 2021, 2:59am UTC](https://discuss.elastic.co/t/stop-token-filter-how-to-set-whitespace-char-as-stop-word-in-stopwords-path-config-file/282429/1 "2021-08-25T02:59:42Z")

</div>

**Elasticsearch 7.5**  
thank you for help me !

i want to set the stop word by the stopwords\_path , i set a lot word in the `stopwords.txt` file , most of the word in the file is effective but only the whitespace char is not effective

```auto
PUT jieba_test
{
  "settings": {
    "analysis": {
      "filter": {
        "jieba_stop": {
          "type": "stop",
          "stopwords_path": "stopwords.txt"
        }
      },
      "analyzer": {
        "my_ana": {
          "tokenizer": "jieba_index",
          "filter": [
            "lowercase",
            "jieba_stop"
          ]
        }
      }
    }
  }
}

```

when i change the setting by `stopwords` setting like below ,it is ok

```auto
PUT jieba_test02
{
  "settings": {
    "analysis": {
      "filter": {
        "jieba_stop": {
          "type": "stop",
          "stopwords": [" ", "is", "the"]
        }
      },
      "analyzer": {
        "my_ana": {
          "tokenizer": "jieba_index",
          "filter": [
            "lowercase",
            "jieba_stop"
          ]
        }
      }
    }
  }
}

```

i want to know , how could i setting whitespace char as stop token in the config file sorry for bother you

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [August 25, 2021, 9:36am UTC](https://discuss.elastic.co/t/stop-token-filter-how-to-set-whitespace-char-as-stop-word-in-stopwords-path-config-file/282429/2 "2021-08-25T09:36:22Z")

</div>

from a quick look in the source this does not seem to be supported. The code to load stop words from file is ultimately this one here [elasticsearch/Analysis.java at master · elastic/elasticsearch · GitHub](https://github.com/elastic/elasticsearch/blob/master/server/src/main/java/org/elasticsearch/index/analysis/Analysis.java#L239-L253)

this calls

```java
if (Strings.hasText(word) == false) {
  continue;
}

```

so if an empty line is encountered (lines that contain only whitespace are also considered empty), that line is skipped.

---

<div class="post-metadata">

**Author:** ![chenchuangc](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/chenchuangc/32/40017_2.png) [@chenchuangc](https://discuss.elastic.co/u/chenchuangc)\
**Post date:** [September 14, 2021, 1:02pm UTC](https://discuss.elastic.co/t/stop-token-filter-how-to-set-whitespace-char-as-stop-word-in-stopwords-path-config-file/282429/4 "2021-09-14T13:02:52Z")

</div>

thank you so much 💗

---

<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 12, 2021, 1:03pm UTC](https://discuss.elastic.co/t/stop-token-filter-how-to-set-whitespace-char-as-stop-word-in-stopwords-path-config-file/282429/5 "2021-10-12T13:03:15Z")

</div>

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