首页 文章

如何读取分面搜索查询的JSON输出?

提问于
浏览
1

我正在播放属于某种类型且具有多个评级的电影 . 使用ElasticSearch,我想先在Genres上进行分面搜索,然后再进行评分 .

我在这里读到这个想法:http://www.elasticsearch.org/guide/reference/api/search/facets/

但我很困惑如何理解这个Curl查询的输出:

curl -X POST "http://localhost:9200/movies/_search?pretty=true" -d '
 {
    "query" : { "query_string" : {"query" : "T*"} },
    "facets" : {
      "categories" : { "terms" : {"field" : "categories"} }
    }
  }
'
{
  "took" : 35,
  "timed_out" : false,
  "_shards" : {
    "total" : 5,
    "successful" : 5,
    "failed" : 0
  },
  "hits" : {
    "total" : 3,
    "max_score" : 1.0,
    "hits" : [ {
      "_index" : "movies",
      "_type" : "movie",
      "_id" : "13",
      "_score" : 1.0, "_source" : {"category_id":2,"created_at":"2013-05-03T16:40:21Z","description":null,"title":"Tiny Plastic Men","updated_at":"2013-05-03T16:40:21Z","user_id":null}
    }, {
      "_index" : "movies",
      "_type" : "movie",
      "_id" : "32",
      "_score" : 1.0, "_source" : {"category_id":14,"created_at":"2013-05-03T16:55:02Z","description":null,"title":"The Extreme Truth","updated_at":"2013-05-03T16:55:02Z","user_id":null}
    }, {
      "_index" : "movies",
      "_type" : "movie",
      "_id" : "39",
      "_score" : 1.0, "_source" : {"category_id":7,"created_at":"2013-05-03T16:55:02Z","description":null,"title":"A Time of Day","updated_at":"2013-05-03T16:55:02Z","user_id":null}
    } ]
  },
  "facets" : {
    "categories" : {
      "_type" : "terms",
      "missing" : 3,
      "total" : 0,
      "other" : 0,
      "terms" : [ ]
    }
  }

我正在播放一些以'T'开头的电影,但另外我会期待来自流派/类别'惊悚片'的电影 .

因此,我可以从上面的JSON中读到什么?

2 回答

相关问题