[英]What is use of fields in Elasticsearch?
有一个type
参数,其值是文本,在fields
又有另一个type
参数,其值是文本。 我不明白english
和another
是什么意思。 您能告诉我什么是fields
参数的功能,我们如何简单地使用它们或从中受益?
PUT my_index
{
"mappings": {
"my_type": {
"properties": {
"text": {
"type": "text",
"fields": {
"english": {
"type": "text",
"analyzer": "english"
},
"another": {
"type": "keyword",
"analyzer": "standard"
}
}
}
}
}
}
}
这种结构称为多场 。
其背后的想法是能够对每个子字段应用不同的分析管道。 在你的情况下, text.english
子场将使用分析english
分析和text.another
子场将通过分析standard
分析 。
这样做的text.english
是您的文档只需要一个text
字段,然后在查询中就可以透明地引用text
, text.english
和text.another
子字段。
# Your document
{
"text": "The nice dog runs after the cat"
}
将此文档编入索引后,
text.english
子字段中,您将具有以下标记: nice
, dog
, run
, after
, cat
text.another
子场你将有以下标记: the
, nice
, dog
, runs
, after
, the
, cat
text
字段中,您将拥有与text.another
相同的标记。 text.another
原因是,当在文本字段中未指定分析器时, standard
分析器也是默认的分析器。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.