Thank you for replying.
localhost:9200/_ingest/pipeline/attachment
{
"attachment": {
"description": "Extract attachment information",
"processors": [
{
"attachment": {
"field": "payload",
"indexed_chars": "-1",
"properties": [
"content",
"content_type",
"content_length",
"title",
"language"
]
},
"remove": {
"field": "payload"
}
}
]
} }
localhost:9200/payload_index/my_type/_mapping
{
"payload_index": {
"mappings": {
"my_type": {
"properties": {
"attachment": {
"properties": {
"content": {
"type": "text",
"fields": {
"_lowercase": {
"type": "text",
"analyzer": "_lowercase"
}
},
"analyzer": "english"
},
"content_length": {
"type": "long"
},
"content_type": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"language": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"title": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
}
}
},
"payload": {
"type": "text",
"fields": {
"_lowercase": {
"type": "text",
"analyzer": "_lowercase"
}
},
"analyzer": "english"
}
}
}
}
} }
There is a peace of code how I index a document:
TransportClient transportClient = new PreBuiltTransportClient( Settings.builder()
.put( "cluster.name", "my_cluster" )
.put( "node.name", "my_node" ).build() )
.addTransportAddresses( new InetSocketTransportAddress(
InetAddress.getByName( "127.0.0.1" ),
elasticConf().getPortNumber( 9300) ) );
XContentBuilder xContentBuilder = jsonBuilder().startObject();
xContentBuilder.field( "payload", bytes );
IndexRequestBuilder requestBuilder = transportClient.prepareIndex( "payload_index", "my_type", id );
requestBuilder.setPipeline( "attachment" );
requestBuilder.setSource( xContentBuilder.endObject() ).execute().actionGet();
localhost:9200/payload_index/my_type/_search
{
"took": 1,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"failed": 0
},
"hits": {
"total": 1,
"max_score": 1,
"hits": [
{
"_index": "payload_index",
"_type": "my_type",
"_id": "1",
"_score": 1,
"_source": {
"attachment": {
"content_type": "text/plain; charset=ISO-8859-1",
"language": "en",
"content": "Test attachment content.",
"content_length": 24
}
}
}
]
} }
Really I don't need BASE64 attachment.