es查询

标题和内容查询:

匹配标题和内容,并且按照时间倒序算权重

{
"_source":["publishtime","title","content"],
"query": {
"function_score": {
"query": {
"bool": {
"must": [
{
"range": {
"publishtime":{"gte":"2018-01-01T00:00:00"}
}
},
{
"term": {
"state": "published"
}
},
{
"multi_match": {"query": "文化旅游部","type":"best_fields","fields":["title^2","content"]}
}
]
}
},
"script_score": {
"script": "return doc['publishtime'].value.toInstant().toEpochMilli() > 1641108584000L ? 20 : 5.0"
},
"boost_mode": "sum"
}

}

}

匹配查询:

{"query":{"more_like_this":{"fields":["textcontent","textrank"],"like":"故宫博物馆","min_term_freq":1,"max_query_terms":100}}}

{
"size": 10,//每页返回条数
"from": 10,//分页从第几页开始
"query": {
"bool": {
"must": [
{
"term": {
"release_terminal": 2//某个属性
}
},
{
"range": {
"download": {
"gte": "2022-01-01 12:03:50"//时间范围
}
}
},
{
"more_like_this": {
"fields": [
"title",
"textcontent",
"textrank"
],
"like": "张家港",
"min_term_freq": 1,
"max_query_terms": 100
}
}
]
}
}
}

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容