Elasticsearch(二)
程序员文章站
2022-07-05 07:51:01
...
1.索引的几种查询
1.query sting search
GET /ecummerce/product/_search
1.took :耗费了几毫秒
2.timed_out 是否超时 这里没有
3._shards :数据拆成了一份,所以对于搜索请求,会打到所有primary shard(或者是它的某个replica shard 也可以)
4.hits.total 查询结果的数量 3个document
5.hits.max_score :score 的含义 就是document对于一个search的相关的匹配分数,越相关,就越匹配 分数越高。
6.hits.hits:包含了匹配搜索的document的详细的数据
{
"took" : 438,
"timed_out" : false,
"_shards" : {
"total" : 1,
"successful" : 1,
"skipped" : 0,
"failed" : 0
},
"hits" : {
"total" : {
"value" : 3,
"relation" : "eq"
},
"max_score" : 1.0,
"hits" : [
{
"_index" : "ecummerce",
"_type" : "product",
"_id" : "2",
"_score" : 1.0,
"_source" : {
"name" : "jiajieshi yagao",
"desc" : "jiajieshi fangzhu",
"price" : 25,
"product" : "jiajieshi producter",
"tags" : [
"fengzhu"
]
}
},
{
"_index" : "ecummerce",
"_type" : "product",
"_id" : "3",
"_score" : 1.0,
"_source" : {
"name" : "zhonghua yagao",
"desc" : "caoben zhizu",
"price" : 40,
"product" : "zhonghua producter",
"tags" : [
"qingxin"
]
}
},
{
"_index" : "ecummerce",
"_type" : "product",
"_id" : "1",
"_score" : 1.0,
"_source" : {
"name" : "gaolujie yagao",
"desc" : "gaoxiao meibai",
"price" : 30,
"product" : "gaolujie producter",
"tags" : [
"fengzhu",
"meibai"
]
}
}
]
}
}