如何根据多种条件从亚马逊弹性搜索中搜索数据?

时间:2017-11-29 07:10:08

标签: json amazon-web-services aws-elasticsearch

我已推送下面的JSON文档

{
"Apartment_Area": "marathahali",
 "Apartment_bhk": "2bhk",
 "Apartment_owner": "praveen",
 "Apartment_forSale": "sold_out"
}
{
 "Apartment_Area": "kadugodi",
 "Apartment_bhk": "1bhk",
 "Apartment_owner": "praveen",
 "Apartment_forSale": "for_sale"
}

现在我尝试使用下面的查询从弹性搜索中搜索1bhk和2 bhk,它给了我1 bhk和2 bhk的JSON数据。

/ _搜索漂亮&安培; Q = 1bhk,2bhk

现在我正在尝试使用名称1 bhk获取Praveen,这意味着我只想查看1 bhk名称为Praveen的数据

对此任何想法的查询是什么?在此先感谢:)

1 个答案:

答案 0 :(得分:1)

Elasticsearch有很好的文档,请查看文档here: 尝试使用以下正文POST/_search?pretty

{
    "query" : {
        "constant_score" : {
            "filter" : {
                "terms" : {
                    "Apartment_bhk" : ["1bhk", "2bhk"]
                }
            }
        }
    }
}