不确定这是错误还是我遗漏了什么。但是,条款方面对于条款数量的返回计数错误。
我的字段有str_tag_analyzer
。
我想从字段中获取Tag Cloud。我想获得前20个标签以及他们的计数(他们出现了多少次)。
术语方面看起来是这种情况的解决方案。我理解,术语构面查询中的大小参数控制将返回多少个标记。
当我运行不同大小的术语构面查询时,我得到意想不到的结果。以下是我的一些疑问及其结果。
查询1
curl -XGET 'http://server:9200/stage_profiles/wrapper_0/_search?pretty=1' -d '
{
query : {
"nested" : {
"query" : {
"field" : {
"gsid" : 222
}
},
"path" : "medals"
}
}, from: 0, size: 0
,
facets: {
"tags" : { "terms" : {"field" : "field_val_t", size: 1} }
}
}'
{
"took" : 1,
"timed_out" : false,
"_shards" : {
"total" : 3,
"successful" : 3,
"failed" : 0
},
"hits" : {
"total" : 189,
"max_score" : 1.0,
"hits" : [ ]
},
"facets" : {
"tags" : {
"_type" : "terms",
"missing" : 57,
"total" : 331,
"other" : 316,
"terms" : [ {
"term" : "hyderabad",
"count" : 15
} ]
}
}
查询2
curl -XGET 'http://server:9200/stage_profiles/wrapper_0/_search?pretty=1' -d '
{
query : {
"nested" : {
"query" : {
"field" : {
"gsid" : 222
}
},
"path" : "medals"
}
}, from: 0, size: 0
,
facets: {
"tags" : { "terms" : {"field" : "field_val_t", size: 3} }
}
}'
{
"took" : 1,
"timed_out" : false,
"_shards" : {
"total" : 3,
"successful" : 3,
"failed" : 0
},
"hits" : {
"total" : 189,
"max_score" : 1.0,
"hits" : [ ]
},
"facets" : {
"tags" : {
"_type" : "terms",
"missing" : 57,
"total" : 331,
"other" : 282,
"terms" : [ {
"term" : "playing",
"count" : 20
}, {
"term" : "hyderabad",
"count" : 15
}, {
"term" : "pune",
"count" : 14
} ]
}
}
}
查询3
curl -XGET 'http://server:9200/stage_profiles/wrapper_0/_search?pretty=1' -d '
{
query : {
"nested" : {
"query" : {
"field" : {
"gsid" : 222
}
},
"path" : "medals"
}
}, from: 0, size: 0
,
facets: {
"tags" : { "terms" : {"field" : "field_val_t", size: 10} }
}
}'
{
"took" : 1,
"timed_out" : false,
"_shards" : {
"total" : 3,
"successful" : 3,
"failed" : 0
},
"hits" : {
"total" : 189,
"max_score" : 1.0,
"hits" : [ ]
},
"facets" : {
"tags" : {
"_type" : "terms",
"missing" : 57,
"total" : 331,
"other" : 198,
"terms" : [ {
"term" : "playing",
"count" : 20
}, {
"term" : "hyderabad",
"count" : 19
}, {
"term" : "bangalore",
"count" : 18
}, {
"term" : "pune",
"count" : 16
}, {
"term" : "chennai",
"count" : 16
}, {
"term" : "games",
"count" : 13
}, {
"term" : "testing",
"count" : 11
}, {
"term" : "cricket",
"count" : 9
}, {
"term" : "singing",
"count" : 6
}, {
"term" : "movies",
"count" : 5
} ]
}
}
}
我有以下顾虑 1.第一个查询给出计数为15的标记,但是存在另一个计数为20的标记(可以在查询2和3中看到)。所以它必须返回计数为20的“播放”标签。 2.第二个查询将“hyderabad”标记的计数返回为15,但对于同一标记,第三个查询返回计数为19。
如果您需要任何其他信息,如ES中的数据,请告知我们。 谢谢