我正在使用elastic-search-1.4.4。这是我的查询:
{
"query": {
"filtered": {
"filter": { "term": { "Name": "n" } }
}
}
}
这是我的索引文件:
{
"took" : 2,
"timed_out" : false,
"_shards" : {
"total" : 5,
"successful" : 5,
"failed" : 0
},
"hits" : {
"total" : 12,
"max_score" : 1.0,
"hits" : [ {
"_index" : "mytry",
"_type" : "users",
"_id" : "23",
"_score" : 1.0,
"_source":{"ID":23,"Name":"Abudul Rafay","Email":"a","Password":"afasd"}
}, {
"_index" : "mytry",
"_type" : "users",
"_id" : "28",
"_score" : 1.0,
"_source":{"ID":28,"Name":"helo","Email":"helo","Password":"heko"}
}, {
"_index" : "mytry",
"_type" : "users",
"_id" : "30",
"_score" : 1.0,
"_source":{"ID":30,"Name":"nup","Email":"nup","Password":"nup"}
}, {
"_index" : "mytry",
"_type" : "users",
"_id" : "31",
"_score" : 1.0,
"_source":{"ID":31,"Name":"apex","Email":"apex","Password":"apex"}
}, {
"_index" : "mytry",
"_type" : "users",
"_id" : "29",
"_score" : 1.0,
"_source":{"ID":29,"Name":"change","Email":"change","Password":"change"}
}, {
"_index" : "mytry",
"_type" : "users",
"_id" : "24",
"_score" : 1.0,
"_source":{"ID":24,"Name":"rafay","Email":"hello","Password":"fasfas"}
}, {
"_index" : "mytry",
"_type" : "users",
"_id" : "32",
"_score" : 1.0,
"_source":{"ID":32,"Name":"newtry","Email":"newtry","Password":"newtry"}
}, {
"index" : "mytry",
"_type" : "users",
"_id" : "25",
"_score" : 1.0,
"_source":{"ID":25,"Name":"r rafay ","Email":"r rafay","Password":"r rafay"}
}, {
"_index" : "mytry",
"_type" : "users",
"_id" : "19",
"_score" : 1.0,
"_source":{"ID":19,"Name":"n","Email":"a","Password":"a"}
}, {
"_index" : "mytry",
"_type" : "users",
"_id" : "26",
"_score" : 1.0,
"_source":{"ID":26,"Name":"New User","Email":"New","Password":"new"}
} ]
}
}
以上是运行以上查询后的结果:
{
"took" : 2,
"timed_out" : false,
"_shards" : {
"total" : 5,
"successful" : 5,
"failed" : 0
},
"hits" : {
"total" : 1,
"max_score" : 1.0,
"hits" : [ {
"_index" : "mytry",
"_type" : "users",
"_id" : "19",
"_score" : 1.0,
"_source":{"ID":19,"Name":"n","Email":"a","Password":"a"}
} ]
}
}
所以,我想获取所有已启动的记录或在名称字段中包含单词'n'。我已尝试使用聚合但不起作用。
答案 0 :(得分:1)