ov7*_*v7a 8 querying elasticsearch
我正在使用Elasticsearch v2.3.0.假设我有一个带映射的索引:
{
"mappings": {
"post": {
"dynamic": false,
"_source": {
"enabled": true
},
"properties": {
"text": {
"norms": {
"enabled": false
},
"fielddata": {
"format": "disabled"
},
"analyzer": "text_analyzer",
"type": "string"
},
"subfield": {
"properties": {
"subsubfield": {
"properties": {
"subtext": {
"index": "no",
"analyzer": "text_analyzer",
"type": "string",
"copy_to": "text"
}
}
}
}
}
},
"_all": {
"enabled": false
}
}
}
Run Code Online (Sandbox Code Playgroud)
所以,从文本subfield.subsubfield.subtext
复制到文本field
因copy_to
.如果你查询信息,然后从纯数据text
显示在text
现场,因为_source
不被修改.如果要获取所有文本,则应聚合客户端上的所有字段.如果存在许多子场,则这可能是不方便的.
是否有一个神奇的查询,它允许获取text
所有文本复制到它的字段?
kee*_*ety 10
在text
字段集的映射中,"store":"yes"
您应该能够使用字段来获取它
示例:
put test/test/_mapping
{
"properties" : {
"name" : { "type" : "string","copy_to": "text"},
"text" : {"type" : "string" ,"store" :"yes"},
"subfield": {
"properties": {
"subsubfield": {
"properties": {
"subtext": {
"index": "no",
"type": "string",
"copy_to": "text"
}
}
}
}
}
}
}
put test/test/1
{
"name" : "hello",
"subfield" : {
"subsubfield" : [
{"subtext" : "soundgarden" },
{"subtext" : "alice in chains" },
{"subtext" : "dio" }
]
}
}
post test/_search
{
"fields": [
"text"
]
}
Run Code Online (Sandbox Code Playgroud)
结果
{
"took": 2,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"failed": 0
},
"hits": {
"total": 1,
"max_score": 1,
"hits": [
{
"_index": "test",
"_type": "test",
"_id": "1",
"_score": 1,
"fields": {
"text": [
"hello",
"soundgarden",
"alice in chains",
"dio"
]
}
}
]
}
}
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
5030 次 |
最近记录: |