创建文档时的ElasticSearch Format字段 [英] ElasticSearch Format field on document creation
本文介绍了创建文档时的ElasticSearch Format字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个包含1个字段的映射:
I have a mapping with 1 field:
"message" : {
"type" : "text"
}
我插入一个新文档:
"message" : " 123 "
是否可以通过ES功能更改字段文本(修饰)?
目的是为消息"字段创建标准.
澄清:不是针对反向索引过滤文本,而是针对原始文本.
Is it possible to change field text (trim) via ES functionality?
The purpose is to create a standard for field "message".
Clarification: Not to filter text for reverse index, but for original text.
必需的输出应为:
{
"message" : "123"
}
推荐答案
是的,您可以使用 修剪
处理器.
Yes, you can achieve that using an ingest pipeline with a trim
processor.
首先定义提取管道:
PUT _ingest/pipeline/my-pipeline
{
"description": "My ingest pipeline",
"processors": [
{
"trim": {
"field": "message"
}
}
]
}
然后只需指定索引文档时要使用的管道:
Then simply specify the pipeline to use when indexing your documents:
PUT my-index/doc/1?pipeline=my-pipeline
{
"message": " 123 "
}
然后您会看到开头和结尾的空格已被删除
Then you can see that the leading and trailing whitespaces have been removed
GET my-index/doc/1
=>
{
"message": "123"
}
这篇关于创建文档时的ElasticSearch Format字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文