修正查询
This commit is contained in:
@@ -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{}{
|
||||
|
Reference in New Issue
Block a user