# When type is text, setting "index" to "not\_analyzed" does not seem to work

**URL:** <https://discuss.elastic.co/t/when-type-is-text-setting-index-to-not-analyzed-does-not-seem-to-work/135283>\
**Category:** Elasticsearch\
**Created:** [June 11, 2018, 3:51am UTC](https://discuss.elastic.co/t/when-type-is-text-setting-index-to-not-analyzed-does-not-seem-to-work/135283 "2018-06-11T03:51:30Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![hubiao](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/hubiao/32/26178_2.png) [@hubiao](https://discuss.elastic.co/u/hubiao)\
**Post date:** [June 11, 2018, 3:51am UTC](https://discuss.elastic.co/t/when-type-is-text-setting-index-to-not-analyzed-does-not-seem-to-work/135283/1 "2018-06-11T03:51:30Z")

</div>

```
"properties": {
  "columns": {
    "properties": {
      "id": {
        "type": "keyword",
        "index": "not_analyzed"
      },
      "name": {
        "type": "keyword",
        "index": "not_analyzed"
      },
      "siteId": {
        "type": "keyword",
        "index": "not_analyzed"
      }
    }
  },
  "text": {
    "type": "text",
    "store": "false",
    "analyzer": "hanlp",
    "fields": {
      "keyword": {
        "type": "text",
        "index": "not_analyzed",
        "fielddata": "true"
      }
    }
  }
}

```

**In order to achieve fuzzy queries, I use the following ways to query:**

```
GET/book_page/book_page/_search
{
      "from": 0,
      "size": 10,
      "query": {
        "bool": {
          "must": [
            {
              "script": {
                "script": {
                  "inline": "doc['text_nlp_sore.keyword'].value!=null&&doc['text_nlp_sore.keyword'].value.indexOf(params.a)!=-1",
                  "lang": "painless",
                  "params": {
                    "a": "中文"
                  }
                }
              }
            }
          ]
        }
      },
      "sort": [
        {
          "_script": {
            "script": {
              "inline": "String myText=doc['text_nlp_sore.keyword'].value;if(myText!=null){int count=0;int index=-1;while((index=myText.indexOf(params.a))!=-1){count++;myText=myText.substring(index+params.a.length())}return Math.log(count);}else{return 0;}",
              "lang": "painless",
              "params": {
                "a": "中文"
              }
            },
            "type": "string",
            "order": "desc"
          }
        },
        {
          "bookDate_date_sore": {
            "order": "desc"
          }
        }
      ],
      "highlight": {
        "fields": {
          
        }
      }
    }

```

But what search does not come out, I doubt that the doc['text\_nlp\_sore.keyword'].value value is participle? But I clearly set up "index": "not\_analyzed". So I want to know if I have made any mistake in that part, or did my doc get the wrong way, please tell me. Thank you

---

<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 9, 2018, 3:51am UTC](https://discuss.elastic.co/t/when-type-is-text-setting-index-to-not-analyzed-does-not-seem-to-work/135283/2 "2018-07-09T03:51:30Z")

</div>

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