It would be most convenient if I was able to get back the indexed struct from my Bleve SearchResults
. This is what I know and what I have:
I have SearchResults.Hits
which I can iterate over, and get the Document with index.Document(hit.ID)
. With the document, I also have access to its fields. What I could do is manually reconstruct the struct. However, in another question about Bleve on here it was mentioned that one can use index.GetInternal(hit.ID)
to get back the original struct, if Index Internal has been set. There is index.SetInternal(key, val []byte) error
, but I am very much at a loss for how to use this accomplish what I wish to. I dug in to the code, but it honestly didn't offer my limited knowledge any insight. How could I set it up so that I only need to invoke index.GetInternal
to retrieve a struct from my search results?
How to recover the struct from a Document in Golang package, Bleve
237 views Asked by Derek At
1
Marty Schoch does not recommend that solution anymore.
What he suggested instead is:
Source: https://gist.github.com/michaeljs1990/25f9949c10ab64d971422dda44feea0e