Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Serializing a struct and its methods for later reuse #828

Open
@ChrisTrenkamp

Description

@ChrisTrenkamp

Here's the backstory.

Let's say you have a static web site and you want to provide a search via a pre-populated search index. So you write a little program to read in the content of your site and create some search indices. We can use Bleve and utilize its in-memory store since it doesn't rely on os-specific functionality like mmap.

package main

import "github.com/blevesearch/bleve"

func createIndex(idx bleve.Index) {
	//Some code for walking the website and populating the index...
}

func main() {
	index, _ := bleve.NewMemOnly(bleve.NewIndexMapping())
	createIndex(index)
	// The Bleve store is now populated with your sites search indices...
	// ... now what?
}

Given the above pseudocode, being ran with GopherJS, to create the search indices, is there a way to serialize it to a file so it can be pulled in by the website? The above link shows ways to use GopherJS to build an index using GopherJS, but I can't figure out how to use GopherJS to generate a pre-built search index.

Any help will be appreciated.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions