构建垂直搜索引擎 互动版

在线工具推荐: Three.js AI纹理开发包 - YOLO合成数据生成器 - GLTF/GLB在线编辑 - 3D模型格式在线转换 - 可编程3D场景编辑器

ES数据检索


  ES中已经存储了我们需要的数据,我们现在要通过ES的request body来查找属性为“content”,值可以匹配“编程”的记录,代码如下:

curl -XGET 'http://localhost:9200/article_one/detail/_search' -d '
 {
    "query":
       {
       "match":
         {"content":"编程"}
       }
  }'

查询结果返回如下:

{
  "took" : 5,
  "timed_out" : false,
  "_shards" : {
    "total" : 5,
    "successful" : 5,
    "failed" : 0
  },
  "hits" : {
    "total" : 1,
    "max_score" : 0.076713204,
    "hits" : [ {
      "_index" : "article_one",
      "_type" : "detail",
      "_id" : "AU2tlMrXq0fYwjnKKzWI",
      "_score" : 0.076713204,
      "_source":{
    "title":"hello world!",
    "url": "http://www.hubwiz.com",
    "content":"一个在线学习编程的网站"
        }
    } ]
  }
}
在右面的编辑器中去练一练,实现上面的功能。