bleve上的搜索请求返回响应,其中字符串字段是精确的,但数字和日期字段未返回为已过期
{
"back_image": "",
"cover_image": "\\storage\\8\\c9e6325b-8cd8-402b-9e37-54b7119a5c22.png",
"created_at": " \u0001\u0014s\u0002\u000b\r\u001b_,\u0000",
"id": " \u0001@\u001f\u0000\u0000\u0000\u0000\u0000\u0000\u0000",
"score": 0.02789571168954376,
"status": " \u0001\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000",
"tags": "i ",
"time": 1004300,
"title": "MyArtu",
"total": 1,
"type": " \u0001?x\u0000\u0000\u0000\u0000\u0000\u0000\u0000",
"updated_at": " \u0001\u0014t\u001f^\u0010,\u0004T\u0000",
"user_id": " \u0001@\u0010\u0000\u0000\u0000\u0000\u0000\u0000\u0000",
"visibility": " \u0001\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000"}
Bleve无法使用我的数值和日期。
我的映射代码是
publication := bleve.NewDocumentMapping()
publicationCoverImage := bleve.NewTextFieldMapping()
publicationCoverImage.Store = true
publication.AddFieldMappingsAt("cover_image",publicationCoverImage)
publicationId := bleve.NewNumericFieldMapping()
publicationId.Store = true
publication.AddFieldMappingsAt("id", publicationId)
publicationTags := bleve.NewTextFieldMapping()
publicationTags.Store = true
publication.AddFieldMappingsAt("tags", publicationTags)
publicationTitle := bleve.NewTextFieldMapping()
publicationTitle.Store = true
publication.AddFieldMappingsAt("title", publicationTitle)
mapping := bleve.NewIndexMapping()
mapping.AddDocumentMapping("publication",publication)
PublicationIndex, PublicationErr = bleve.New("publications.bleve", mapping)
这是生成输出
的代码for _,hit := range result.Hits {
doc, _ := search.PublicationIndex.Document(hit.ID)
for _, field := range doc.Fields {
resp[string(filed.Name())] = fmt.Sprint(string(filed.Value()))
}
}