修正查询

This commit is contained in:
2023-12-03 15:57:28 +08:00
parent 58c20ac003
commit 7324d27bc1
2 changed files with 6 additions and 19 deletions

View File

@@ -5,6 +5,7 @@ import (
"context"
"crypto/tls"
"encoding/json"
"fmt"
"log"
"net/http"
@@ -55,15 +56,16 @@ type SearchData struct {
}
// 获取搜索结果的 ID 列表
func (sd *SearchData) GetIDList() (id_list []string) {
func (sd SearchData) GetIDList() (id_list []string) {
for _, hit := range sd.Hits.Hits {
id_list = append(id_list, hit.ID)
fmt.Println(hit.Source.Content)
}
return id_list
}
// 获取搜索结果的内容列表
func ElasticsearchSearch(text string) (r *SearchData) {
func ElasticsearchSearch(text string) (r SearchData) {
// 通过字符串构建查询
var buf bytes.Buffer
query := map[string]interface{}{