我正在尝试根据查询访问ElasticSearch中的特定字段。
以下是我的索引结构 -
{
"mappings": {
"product": {
"properties": {
"Color": {
"type": "string", "index":"not_analyzed"
},
"Name": {
"type": "string", "index":"not_analyzed"
},
"ListPrice": {
"type": "double"
},
"StandardCost": {
"type": "double"
}
}
}
}
}
下面是_source -
的查询{
"from" : 0,
"size" : 20,
"_source": [ "Name"],
"query" : { "term" : {"Name" : "Mountain"} }
}
以下是示例文档 -
{
"Color": "Green",
"Name": "Mountain Views",
"ListPrice": 4.00,
"StandardCost": 8.00
}
{
"Color": "Green",
"Name": "Mountain Views",
"ListPrice": 4.00,
"StandardCost": 8.00
}
{
"Color": "Green",
"Name": "Mountain Views",
"ListPrice": 4.00,
"StandardCost": 8.00
}
我在结果中得到了ID,但我没有得到'姓名'字段。
我也试过使用'fields'属性,但我仍然没有得到'Name'字段。
有人可以帮助我吗?
谢谢, 萨米尔