|
|
@ -1,6 +1,7 @@ |
|
|
|
{{template "header" .}} |
|
|
|
<meta name="keywords" content="码农随笔,个人随笔,博客,个人博客,个人笔记,技术博客,免费云笔记,云笔记,随笔,IT博客,谷歌地图,码农笔录,aiprose"> |
|
|
|
<title>搜索 - 码农随笔</title> |
|
|
|
<script src="https://unpkg.com/dayjs@1.8.15/dayjs.min.js"></script> |
|
|
|
</head> |
|
|
|
<body> |
|
|
|
<div class="root-container"> |
|
|
@ -15,34 +16,41 @@ |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
<div> |
|
|
|
<div class="search-result"> |
|
|
|
|
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</body> |
|
|
|
<script> |
|
|
|
var pageNo = 1; |
|
|
|
var pageSize = 30; |
|
|
|
// var pageNo = page; |
|
|
|
var searchParms = { |
|
|
|
from: 0, |
|
|
|
size: 20, |
|
|
|
query: { |
|
|
|
multi_match: { |
|
|
|
query: "linux", |
|
|
|
query: "", |
|
|
|
// type: "best_fields", |
|
|
|
fields: ["Title", "BlogHtml"] |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
$(function () { |
|
|
|
$("#searchBtn").click(function () { |
|
|
|
var searchVal = $("#searchVal").val() |
|
|
|
if (!searchVal || searchVal.trim().length == 0) { |
|
|
|
layer.msg("请输入查询内容") |
|
|
|
return |
|
|
|
} |
|
|
|
searchParms.query.multi_match.query = searchVal; |
|
|
|
var stringify = JSON.stringify(searchParms); |
|
|
|
$.ajax({ |
|
|
|
url: "https://www.aiprose.com/beeblog/beeblog/_search", //请求的url地址 |
|
|
|
headers:{'Content-Type':'application/json;charset=utf8'}, |
|
|
|
url: "http://106.12.3.97:8209/beeblog/beeblog/_search", //请求的url地址 |
|
|
|
headers: {'Content-Type': 'application/json;charset=utf8'}, |
|
|
|
dataType: "json", //返回格式为json |
|
|
|
async: true,//请求是否异步,默认为异步,这也是ajax重要特性 |
|
|
|
data: stringify, //参数值 |
|
|
@ -51,7 +59,17 @@ |
|
|
|
//请求前的处理 |
|
|
|
}, |
|
|
|
success: function (resp) { |
|
|
|
debugger |
|
|
|
if (resp.hits.total != 0) { |
|
|
|
$(".search-result").children().remove(); |
|
|
|
resp.hits.hits.forEach(function (el, index) { |
|
|
|
console.log(el._source) |
|
|
|
var htmlStr = '<div class=\"search-item\">\n' + |
|
|
|
' <div class=\"search-title\"><a href=\"https://www.aiprose.com/blog/' + el._source.Id + '\" target=\"_blank\">' + el._source.Title + '</a><span>' + dayjs(el._source.Ctime).format("YYYY-MM-DD") + '</span></div>\n' + |
|
|
|
' <p class=\"search-content\">' + el._source.BlogDesc + '</p>\n' + |
|
|
|
' </div>' |
|
|
|
$(".search-result").append(htmlStr) |
|
|
|
}) |
|
|
|
} |
|
|
|
//请求成功时处理 |
|
|
|
}, |
|
|
|
complete: function () { |
|
|
|