<commit_before>package factory

import (
	"context"
	"github.com/ipfs-search/ipfs-search/index"
	"github.com/ipfs-search/ipfs-search/index/elasticsearch"
	"github.com/olivere/elastic/v6"
	"log"
	// "os"
)

func getElastic(url string) (*elastic.Client, error) {
	// logger := log.New(os.Stderr, "es", log.LstdFlags)
	// elastic.SetTraceLog(logger)
	el, err := elastic.NewClient(elastic.SetSniff(false), elastic.SetURL(url))
	if err != nil {
		return nil, err
	}

	log.Printf("Connected to ElasticSearch")

	return el, nil
}

func getIndex(ctx context.Context, el *elastic.Client, config *index.Config) (index.Index, error) {
	if config == nil {
		panic("configuration for index nil")
	}

	i := &elasticsearch.Index{
		Client: el,
		Name:   config.Name,
	}

	// Create index if it doesn't already exists, update if it is different (last parameter, true).
	if err := index.EnsureUpdated(ctx, i, config); err != nil {
		return nil, err
	}

	return i, nil
}<commit_msg>Tiny clarification.<commit_after>package factory

import (
	"context"
	"github.com/ipfs-search/ipfs-search/index"
	"github.com/ipfs-search/ipfs-search/index/elasticsearch"
	"github.com/olivere/elastic/v6"
	"log"
	// "os"
)

func getElastic(url string) (*elastic.Client, error) {
	// logger := log.New(os.Stderr, "es", log.LstdFlags)
	// elastic.SetTraceLog(logger)
	el, err := elastic.NewClient(elastic.SetSniff(false), elastic.SetURL(url))
	if err != nil {
		return nil, err
	}

	log.Printf("Connected to ElasticSearch")

	return el, nil
}

func getIndex(ctx context.Context, es *elastic.Client, config *index.Config) (index.Index, error) {
	if config == nil {
		panic("configuration for index nil")
	}

	i := &elasticsearch.Index{
		Client: es,
		Name:   config.Name,
	}

	// Create index if it doesn't already exists, update if it is different (last parameter, true).
	if err := index.EnsureUpdated(ctx, i, config); err != nil {
		return nil, err
	}

	return i, nil
}
{'fraction_non_alphanumeric': 0.1483971044467425, 'fraction_numerical': 0.001034126163391934, 'mean_word_length': 4.025974025974026, 'pattern_counts': {'":': 0, '<': 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': '1039626', 'n_tokens_mistral': 722, 'n_tokens_neox': 691, 'n_words': 171}