func queryIndex(index *structs.Index, rexpstr string) {
	r, err := regexp.Compile(rexpstr)
	if err != nil {
		fmt.Printf("%v\n", err.Error())
		return
	}
	matchedDocsCount, matchedKeywordsCount := 0, 0
	fmt.Println("Docs matched by regexp:")
	for doc := range index.IteratorDocs() {
		docStr := doc.(string)
		if r.MatchString(docStr) {
			matchedDocsCount++
			fmt.Println(docStr)
		}
	}
	fmt.Printf("%v total.\n", matchedDocsCount)
	fmt.Println("Keywords matched by regexp:")
	for keyword := range index.IteratorKeywords() {
		keywordStr := keyword.(string)
		if r.MatchString(keywordStr) {
			fmt.Println(keyword)
			matchedKeywordsCount++
			inDocs := make([]string, 0)
			for doc := range index.IteratorDocsByKeyword(keywordStr) {
				inDocs = append(inDocs, doc.(string))
			}
			fmt.Printf("\tFound in the next %v documents:\n", len(inDocs))
			for _, doc := range inDocs {
				fmt.Printf("\t%v\n", doc)
			}
		}
	}
	fmt.Printf("%v total.\n", matchedKeywordsCount)
}
func listDocs(index *structs.Index, keyword string) {
	fmt.Printf("Documents which contain keyword %q:\n", keyword)
	count := 0
	for doc := range index.IteratorDocsByKeyword(keyword) {
		count++
		fmt.Printf("\t%v\n", doc)
	}
	fmt.Printf("%v in total\n", count)
}