我正在尝试使用elasticsearch布尔查询搜索特定字段和值。我正在使用python请求命中这个端点“http://localhost:9200/index/_search”。
get sports/_search {"query":
{
"bool":
{
"must":
[{
"match":
{
"sport":"cricket"
}
},
{
"match":
{
"age":"42"
}
}]
}
}
}
我收到此回复,在这里我使用python请求来获得响应。
'{"took":2,"timed_out":false,"_shards":{"total":5,"successful":5,"skipped":0,"failed":0},"hits":{"total":0,"max_score":null,"hits":[]}}'
我的索引文件是:
{
"took" : 2,
"timed_out" : false,
"_shards" : {
"total" : 5,
"successful" : 5,
"skipped" : 0,
"failed" : 0
},
"hits" : {
"total" : 1,
"max_score" : 1.0,
"hits" : [
{
"_index" : "sports",
"_type" : "articles",
"_id" : "1",
"_score" : 1.0,
"_source" : {
"mappings" : {
"person2" : {
"details" : {
"debut" : "23 December 2004",
"awards" : "Padma Bhushan, Padma Shri, Rajiv Gandhi Khel Ratna",
"name" : "Dhoni",
"country" : "India",
"dob" : "7 July 1981",
"gender" : "Male",
"age" : "36",
"sport" : "Cricket",
"current_status" : "on-ground"
}
},
"person3" : {
"details" : {
"debut" : "23 December 2004",
"awards" : "Padma Bhushan, Padma Shri, Rajiv Gandhi Khel Ratna",
"name" : "Saina Nehwal",
"country" : "India",
"dob" : "17 March 1990",
"gender" : "Female",
"age" : "28",
"sport" : "Badmiton",
"current_status" : "on-ground"
}
},
"person1" : {
"details" : {
"debut" : "18 December 1989",
"awards" : "Bharat Ratna, Padma Bhushan, Padma Shri, Rajiv Gandhi Khel Ratna",
"name" : "Sachin",
"country" : "India",
"dob" : "24 April 1973",
"gender" : "Male",
"age" : "42",
"sport" : "Cricket",
"current_status" : "retired"
}
},
"person4" : {
"details" : {
"debut" : "23 March 1990",
"awards" : "Padma Bhushan, Padma Shri, Rajiv Gandhi Khel Ratna, Arjuna Award",
"name" : "Leander Paes",
"country" : "India",
"dob" : "17 June 1973",
"gender" : "Male",
"age" : "44",
"sport" : "Badmiton",
"current_status" : "on-ground"
}
}
}
}
}
]
}
}
先谢谢