0

Search request on the bleve returns the response where string fields are exact but numeric and date fields are not returning as expacted

{
"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 is not working with the numeric values and date for me.

My Mapping Code is

    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)

Here is the code that is reponsible generating the output

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()))
        }           
    }
Manish Champaneri
  • 654
  • 3
  • 8
  • 28
  • Could you share more of the code related the problems you're seeing? In particular, the rest of the code around the mapping, and how the mapping is used can result in the entire mapping not being used. Also, can you show the code that produced the JSON snippet at the top. The strange values you see there are similar to the internal representation used for numbers, but shouldn't be returned like that normally. With more complete code producing this we should be able to help. – mschoch Sep 28 '17 at 16:19
  • @mschoch Sorry For this trouble, I was doing a mistake insted of doing for loop i have to just return the result it self. Returning result gives the well formted json with the data. – Manish Champaneri Oct 03 '17 at 08:52

0 Answers0