Elasticsearch需要从查询文档中获取匹配的字段

时间:2017-05-30 09:55:05

标签: elasticsearch

我需要在搜索时只返回返回文档中匹配的字段。

这是我的样本索引:

{
    "_index" : "company",
    "_type" : "data",
    "_id" : "1",
    "_version" : 1,
    "found" : true,
    "_source" : {
        "cpn" : "companycpn",
        "cpn_desc" : "_NA",
        "mpn" : "2-020 TFE_Tri",
        "commodity_name" : "_NA",
        "sub_commodity_name" : "HARDWARE & MISC",
        "manufacturer_name" : "PARKER HANNIFIN",
        "supplier_name" : "ABCDE",
        "product_name" : "NA",
        "product_description" : "NA",
        "product_family_name" : "NA",
        "cm_odm_name" : "CRF",
        "fiscal_year" : "2015",
        "fiscal_quarter" : "1"
    }
}

以下是我正在使用的GET查询:

GET company/data/_search
{
    "query": {
        "query_string": {
            "query": "*parker*"
        }
    },
    "size": 10
}

如果您针对上述查询观察到匹配字段' manufacturer_name'在_source中。我只需要获得这个字段,即我只想从elasticsearch获得给定查询的匹配字段。

有什么办法吗?

0 个答案:

没有答案