<commit_before>package controllers

import (
	"fmt"
	"github.com/gojp/greenbook/app/models"
	"github.com/jgraham909/revmgo"
	"github.com/robfig/revel"
	"labix.org/v2/mgo"
	"labix.org/v2/mgo/bson"
)

type App struct {
	*revel.Controller
	revmgo.MongoController
}

func (a App) Search(search string) revel.Result {
	collection := a.MongoSession.DB("greenbook").C("edict")

	fmt.Println("Searching for... ", search)

	// Index - not the best place for this, but okay for now...
	index := mgo.Index{
		Key:        []string{"romaji", "furigana", "japanese", "glosses"},
		Unique:     false,
		DropDups:   false,
		Background: true,
		Sparse:     true,
	}

	err := collection.EnsureIndex(index)

	if err != nil {
		panic("Database connection failed")
	}

	wordList := []models.Word{}
	query := bson.M{"$or": []bson.M{
		bson.M{"romaji": bson.RegEx{".*" + search + ".*", "i"}},
		bson.M{"furigana": search},
		bson.M{"japanese": search},
	}}
	q := collection.Find(query).Sort("-common", "furigana")
	iter := q.Limit(100).Iter()
	iter.All(&wordList)

	return a.Render(wordList)
}

func (c App) Index() revel.Result {
	return c.Render()
}
<commit_msg>temporarily comment out mgo functionality in app.go<commit_after>package controllers

import (
	"fmt"
	//"github.com/gojp/nihongo/app/models"
	//"github.com/mattbaird/elastigo/api"
	//"github.com/mattbaird/elastigo/search"
	//"github.com/mattbaird/elastigo/core"
	"github.com/robfig/revel"
)

type App struct {
	*revel.Controller
}

func (a App) Search(query string) revel.Result {
	//api.Domain = "localhost"
	//out, err := search.Search("edict").Type("entry").Size("100").Search(query).Result()
	//if err != nil {
	//	fmt.Println(err)
	//}
	//fmt.Println(out)

	fmt.Println("Searching for... ", query)

	// Index - not the best place for this, but okay for now...
	//index := mgo.Index{
	//	Key:        []string{"romaji", "furigana", "japanese", "glosses"},
	//	Unique:     false,
	//	DropDups:   false,
	//	Background: true,
	//	Sparse:     true,
	//}

	//err := collection.EnsureIndex(index)

	//if err != nil {
	//	panic("Database connection failed")
	//}

	//wordList := []models.Word{}
	//query := bson.M{"$or": []bson.M{
	//	bson.M{"romaji": bson.RegEx{".*" + search + ".*", "i"}},
	//	bson.M{"furigana": search},
	//	bson.M{"japanese": search},
	//}}
	//q := collection.Find(query).Sort("-common", "furigana")
	//iter := q.Limit(100).Iter()
	//iter.All(&wordList)

	return a.Render()
}

func (c App) Index() revel.Result {
	return c.Render()
}

{'fraction_non_alphanumeric': 0.20801603206412825, 'fraction_numerical': 0.0056112224448897794, 'mean_word_length': 3.4412811387900355, 'pattern_counts': {'":': 8, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '78184', 'n_tokens_mistral': 1025, 'n_tokens_neox': 988, 'n_words': 187}