Exemplo n.º 1
0
func searchQuery() {
	q := search.Get().NewQuery("Comment").Order("-ts_millis")
	q.NewAndFilter().
		AddRegex("text", "[hH]ard.*easy").
		AddExact("source", "userid")
	docs, _ := q.Run()
	j, _ := json.Marshal(docs)
	fmt.Println(string(j))
}
Exemplo n.º 2
0
func main() {
	path, err := ioutil.TempDir("", "gocrudldb_")
	if err != nil {
		log.Fatal("Opening file")
		return
	}
	store.Get().Init(path) // leveldb
	search.Get().Init()    // memsearch

	ctx := req.NewContextWithUpdates(3, 10) // Number of chars in unique ids.
	indexer.Register("Comment", SimpleIndexer{})
	indexer.Run(ctx, 2)

	storeUpdate(ctx)
	storeQuery()

	indexer.WaitForDone(ctx)
	searchQuery()
}