在字段上使用匹配查询

时间:2017-03-02 22:25:21

标签: elasticsearch

查询索引,查询字符串以匹配任何属性

{
    "size": 2,
     "_source":["awardeeName"],
    "query": {
        "query_string" : {
                "query": "health"
             }
    }
  }         
}

这会返回两条记录

[
{
    "_index": "docm-es",
    "_type": "document",
    "_id": "9d8c832d-f22f-463e-9102-4aefcaff88fa",
    "_score": 0.74211,
    "_source": {
        "awardeeName": "State of Hawaii Department of Health"
    }
},
{
    "_index": "docm-es",
    "_type": "document",
    "_id": "79963a60-8e9e-45ac-b7f8-6dc99f6b0621",
    "_score": 0.6427368,
    "_source": {
        "awardeeName": "New York State Department of Health"
    }
}
]

两个记录都显示,属性awardeename包含word health。 查询以匹配字段awardeeName匹配文本运行状况,

{
    "size": 2,
    "_source":["awardeeName"],
    "query": {
        "match" : {
                "awardeeName": "health"
             }
    }
  }         
}

这不会返回任何点击,有什么不对,在此查询中,请提供建议。

1 个答案:

答案 0 :(得分:0)

您可以通过添加用于此字段的映射来更新问题