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
{
"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
{
"@timestamp": "2017-05-18T15:21:39.465Z",
"filename": "abc.txt",
"sourceSystem": "Test",
"link": "http://192.168.1.1:6000/Login",
"data": "5pWw5a2X5YyW6Kej5Yaz5pa55qGI6aKG5a+86ICF"
}
Post http://localhost:9200/documents/doc/_search?pretty=true
{
"_source": ["@timestamp", "filename", "sourceSystem","link"],
"query": {
"match": {
"attachment.content": "测试目的"
}
},
"highlight": {
"fields": {
"attachment.content": {}
}
}
}