# How to use ik analyzer for ingest-attachment

**URL:** <https://discuss.elastic.co/t/how-to-use-ik-analyzer-for-ingest-attachment/146599>\
**Category:** Elasticsearch\
**Created:** [August 30, 2018, 2:45am UTC](https://discuss.elastic.co/t/how-to-use-ik-analyzer-for-ingest-attachment/146599 "2018-08-30T02:45:24Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![bluce\_zhang](https://avatars.discourse-cdn.com/v4/letter/b/df788c/32.png) [@bluce\_zhang](https://discuss.elastic.co/u/bluce_zhang)\
**Post date:** [August 30, 2018, 2:45am UTC](https://discuss.elastic.co/t/how-to-use-ik-analyzer-for-ingest-attachment/146599/1 "2018-08-30T02:45:25Z")

</div>

Hello, I am using ingest attachment to search document. The requirement need to handle chinese, so we want to use ik as analyzer for attachment.content.

But for some reason it's not working, I think it's still using default analyzer. Below is the json to create index, add document and query.

Any advice will be appreciated, thanks in advanced.

Put [http://localhost:9200/doctest](http://localhost:9200/doctest)  
{  
"settings" : {  
"analysis" : {  
"analyzer" : {  
"ik" : {  
"tokenizer" : "ik\_smart",  
"analyzer" : "ik\_smart"  
}  
}  
}  
},  
"mappings": {  
"doc": {  
"properties": {  
"timestamp": {  
"type": "date"  
},  
"attachment": {  
"properties": {  
"author": {  
"type": "text",  
"analyzer" : "ik\_smart",  
"search\_analyzer": "ik\_smart",  
"fields": {  
"keyword": {  
"type": "keyword",  
"ignore\_above": 256  
}  
}  
},  
"content": {  
"type": "text",  
"analyzer" : "ik\_smart",  
"search\_analyzer": "ik\_smart",  
"fields": {  
"keyword": {  
"type": "keyword",  
"ignore\_above": 256  
}  
}  
},  
"content\_length": {  
"type": "long"  
},  
"content\_type": {  
"type": "text",  
"analyzer" : "ik\_smart",  
"search\_analyzer": "ik\_smart",  
"fields": {  
"keyword": {  
"type": "keyword",  
"ignore\_above": 256  
}  
}  
},  
"date": {  
"type": "date"  
},  
"language": {  
"type": "text",  
"analyzer" : "ik\_smart",  
"search\_analyzer": "ik\_smart",  
"fields": {  
"keyword": {  
"type": "keyword",  
"ignore\_above": 256  
}  
}  
},  
"title": {  
"type": "text",  
"analyzer" : "ik\_smart",  
"search\_analyzer": "ik\_smart",  
"fields": {  
"keyword": {  
"type": "keyword",  
"ignore\_above": 256  
}  
}  
}  
}  
},  
"data": {  
"type": "text",  
"analyzer" : "ik\_smart",  
"search\_analyzer": "ik\_smart",  
"fields": {  
"keyword": {  
"type": "keyword",  
"ignore\_above": 256  
}  
}  
},  
"filename": {  
"type": "text",  
"analyzer" : "ik\_smart",  
"search\_analyzer": "ik\_smart",  
"fields": {  
"keyword": {  
"type": "keyword",  
"ignore\_above": 256  
}  
}  
},  
"link": {  
"type": "text",  
"analyzer" : "ik\_smart",  
"search\_analyzer": "ik\_smart",  
"fields": {  
"keyword": {  
"type": "keyword",  
"ignore\_above": 256  
}  
}  
},  
"sourceSystem": {  
"type": "text",  
"analyzer" : "ik\_smart",  
"search\_analyzer": "ik\_smart",  
"fields": {  
"keyword": {  
"type": "keyword",  
"ignore\_above": 256  
}  
}  
}  
}  
}  
}  
}

Put [http://localhost:9200/documents/doc/0?pipeline=attachment](http://localhost:9200/documents/doc/0?pipeline=attachment)  
{  
"@timestamp": "2017-05-18T15:21:39.465Z",  
"filename": "abc.txt",  
"sourceSystem": "Test",  
"link": "[http://192.168.1.1:6000/Login](http://192.168.1.1:6000/Login)",  
"data": "5pWw5a2X5YyW6Kej5Yaz5pa55qGI6aKG5a+86ICF"  
}

Post [http://localhost:9200/documents/doc/\_search?pretty=true](http://localhost:9200/documents/doc/_search?pretty=true)  
{  
"\_source": ["@timestamp", "filename", "sourceSystem","link"],  
"query": {  
"match": {  
"attachment.content": "测试目的"  
}  
},  
"highlight": {  
"fields": {  
"attachment.content": {}  
}  
}  
}

---

<div class="post-metadata">

**Author:** ![Zhilong\_He](https://avatars.discourse-cdn.com/v4/letter/z/e19adc/32.png) [@Zhilong\_He](https://discuss.elastic.co/u/Zhilong_He)\
**Post date:** [August 30, 2018, 5:02am UTC](https://discuss.elastic.co/t/how-to-use-ik-analyzer-for-ingest-attachment/146599/2 "2018-08-30T05:02:03Z")

</div>

Please try this setting and use `_analyze` API to test `ik_smart` and `ik_max_word` analyzer

```auto
{
  "settings": {},
  "mappings": {
    "doc": {
      "properties": {
        "timestamp": {
          "type": "date"
        },
        "attachment": {
          "properties": {
            "author": {
              "type": "text",
              "analyzer": "ik_max_word",
              "search_analyzer": "ik_max_word",
              "fields": {
                "keyword": {
                  "type": "keyword",
                  "ignore_above": 256
                }
              }
            },
            "content": {
              "type": "text",
              "analyzer": "ik_max_word",
              "search_analyzer": "ik_max_word",
              "fields": {
                "keyword": {
                  "type": "keyword",
                  "ignore_above": 256
                }
              }
            },
            "content_length": {
              "type": "long"
            },
            "content_type": {
              "type": "text",
              "analyzer": "ik_max_word",
              "search_analyzer": "ik_max_word",
              "fields": {
                "keyword": {
                  "type": "keyword",
                  "ignore_above": 256
                }
              }
            },
            "date": {
              "type": "date"
            },
            "language": {
              "type": "text",
              "analyzer": "ik_max_word",
              "search_analyzer": "ik_max_word",
              "fields": {
                "keyword": {
                  "type": "keyword",
                  "ignore_above": 256
                }
              }
            },
            "title": {
              "type": "text",
              "analyzer": "ik_max_word",
              "search_analyzer": "ik_max_word",
              "fields": {
                "keyword": {
                  "type": "keyword",
                  "ignore_above": 256
                }
              }
            }
          }
        },
        "data": {
          "type": "text",
          "analyzer": "ik_max_word",
          "search_analyzer": "ik_max_word",
          "fields": {
            "keyword": {
              "type": "keyword",
              "ignore_above": 256
            }
          }
        },
        "filename": {
          "type": "text",
          "analyzer": "ik_max_word",
          "search_analyzer": "ik_max_word",
          "fields": {
            "keyword": {
              "type": "keyword",
              "ignore_above": 256
            }
          }
        },
        "link": {
          "type": "text",
          "analyzer": "ik_max_word",
          "search_analyzer": "ik_max_word",
          "fields": {
            "keyword": {
              "type": "keyword",
              "ignore_above": 256
            }
          }
        },
        "sourceSystem": {
          "type": "text",
          "analyzer": "ik_max_word",
          "search_analyzer": "ik_max_word",
          "fields": {
            "keyword": {
              "type": "keyword",
              "ignore_above": 256
            }
          }
        }
      }
    }
  }
}

```

---

<div class="post-metadata">

**Author:** ![bluce\_zhang](https://avatars.discourse-cdn.com/v4/letter/b/df788c/32.png) [@bluce\_zhang](https://discuss.elastic.co/u/bluce_zhang)\
**Post date:** [August 30, 2018, 8:01am UTC](https://discuss.elastic.co/t/how-to-use-ik-analyzer-for-ingest-attachment/146599/3 "2018-08-30T08:01:54Z")

</div>

Thanks for reply, I try this index but it make no difference, the response is the same as when i use ik-smart or leave it as default.

I query the mapping, it shows the analyzer change have been made, but just not working.

{  
"doctest": {  
"mappings": {  
"doc": {  
"properties": {  
"attachment": {  
"properties": {  
"author": {  
"type": "text",  
"fields": {  
"keyword": {  
"type": "keyword",  
"ignore\_above": 256  
}  
},  
"analyzer": "ik\_max\_word"  
},  
"content": {  
"type": "text",  
"fields": {  
"keyword": {  
"type": "keyword",  
"ignore\_above": 256  
}  
},  
"analyzer": "ik\_max\_word"  
},  
"content\_length": {  
"type": "long"  
},  
"content\_type": {  
"type": "text",  
"fields": {  
"keyword": {  
"type": "keyword",  
"ignore\_above": 256  
}  
},  
"analyzer": "ik\_max\_word"  
},  
"date": {  
"type": "date"  
},  
"language": {  
"type": "text",  
"fields": {  
"keyword": {  
"type": "keyword",  
"ignore\_above": 256  
}  
},  
"analyzer": "ik\_max\_word"  
},  
"title": {  
"type": "text",  
"fields": {  
"keyword": {  
"type": "keyword",  
"ignore\_above": 256  
}  
},  
"analyzer": "ik\_max\_word"  
}  
}  
},  
"data": {  
"type": "text",  
"fields": {  
"keyword": {  
"type": "keyword",  
"ignore\_above": 256  
}  
},  
"analyzer": "ik\_max\_word"  
},  
"filename": {  
"type": "text",  
"fields": {  
"keyword": {  
"type": "keyword",  
"ignore\_above": 256  
}  
},  
"analyzer": "ik\_max\_word"  
},  
"link": {  
"type": "text",  
"fields": {  
"keyword": {  
"type": "keyword",  
"ignore\_above": 256  
}  
},  
"analyzer": "ik\_max\_word"  
},  
"sourceSystem": {  
"type": "text",  
"fields": {  
"keyword": {  
"type": "keyword",  
"ignore\_above": 256  
}  
},  
"analyzer": "ik\_max\_word"  
},  
"timestamp": {  
"type": "date"  
}  
}  
}  
}  
}  
}

---

<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:** [September 27, 2018, 9:53am UTC](https://discuss.elastic.co/t/how-to-use-ik-analyzer-for-ingest-attachment/146599/5 "2018-09-27T09:53:42Z")

</div>

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