func ExampleNewClientFromPool_ssl() {
	// Consider the following helper methods that provide us with the connection details (host and password)
	// and the paths for:
	//     tls_cert - A a X.509 certificate to use for authenticating the  server to connected clients, masters or cluster peers. The file should be PEM formatted
	//     tls_key - A a X.509 private key to use for authenticating the  server to connected clients, masters or cluster peers. The file should be PEM formatted
	//	   tls_cacert - A PEM encoded CA's certificate file
	host, password := getConnectionDetails()
	tlsready, tls_cert, tls_key, tls_cacert := getTLSdetails()

	// Skip if we dont have all files to properly connect
	if tlsready == false {
		return
	}

	// Load client cert
	cert, err := tls.LoadX509KeyPair(tls_cert, tls_key)
	if err != nil {
		log.Fatal(err)
	}

	// Load CA cert
	caCert, err := ioutil.ReadFile(tls_cacert)
	if err != nil {
		log.Fatal(err)
	}
	caCertPool := x509.NewCertPool()
	caCertPool.AppendCertsFromPEM(caCert)

	clientTLSConfig := &tls.Config{
		Certificates: []tls.Certificate{cert},
		RootCAs:      caCertPool,
	}

	// InsecureSkipVerify controls whether a client verifies the
	// server's certificate chain and host name.
	// If InsecureSkipVerify is true, TLS accepts any certificate
	// presented by the server and any host name in that certificate.
	// In this mode, TLS is susceptible to man-in-the-middle attacks.
	// This should be used only for testing.
	clientTLSConfig.InsecureSkipVerify = true

	pool := &redis.Pool{Dial: func() (redis.Conn, error) {
		return redis.Dial("tcp", host,
			redis.DialPassword(password),
			redis.DialTLSConfig(clientTLSConfig),
			redis.DialUseTLS(true),
			redis.DialTLSSkipVerify(true),
		)
	}}

	c := redisearch.NewClientFromPool(pool, "search-client-1")

	// Create a schema
	sc := redisearch.NewSchema(redisearch.DefaultOptions).
		AddField(redisearch.NewTextField("body")).
		AddField(redisearch.NewTextFieldOptions("title", redisearch.TextFieldOptions{Weight: 5.0, Sortable: true})).
		AddField(redisearch.NewNumericField("date"))

	// Drop an existing index. If the index does not exist an error is returned
	c.Drop()

	// Create the index with the given schema
	if err := c.CreateIndex(sc); err != nil {
		log.Fatal(err)
	}

	// Create a document with an id and given score
	doc := redisearch.NewDocument("ExampleNewClientFromPool_ssl:doc3", 1.0)
	doc.Set("title", "Hello world").
		Set("body", "foo bar").
		Set("date", time.Now().Unix())

	// Index the document. The API accepts multiple documents at a time
	if err := c.Index([]redisearch.Document{doc}...); err != nil {
		log.Fatal(err)
	}

	// Searching with limit and sorting
	docs, total, err := c.Search(redisearch.NewQuery("hello world").
		Limit(0, 2).
		SetReturnFields("title"))

	fmt.Println(docs[0].Id, docs[0].Properties["title"], total, err)
}
//Example of how to establish an SSL connection from your app to the RedisAI Server
Example of how to establish an SSL connection from your app to the RedisAI Server
// Example of how to establish an SSL connection from your app to the RedisAI Server
func ExampleNewClientFromPool_ssl() {
	host, password := getConnectionDetails()
	tlsready, tls_cert, tls_key, tls_cacert := getTLSdetails()
	if tlsready == false {
		return
	}
	cert, err := tls.LoadX509KeyPair(tls_cert, tls_key)
	if err != nil {
		log.Fatal(err)
	}
	caCert, err := ioutil.ReadFile(tls_cacert)
	if err != nil {
		log.Fatal(err)
	}
	caCertPool := x509.NewCertPool()
	caCertPool.AppendCertsFromPEM(caCert)
	clientTLSConfig := &tls.Config{
		Certificates: []tls.Certificate{cert},
		RootCAs:      caCertPool,
	}
	clientTLSConfig.InsecureSkipVerify = true
	pool := &redis.Pool{Dial: func() (redis.Conn, error) {
		return redis.Dial("tcp", host,
			redis.DialPassword(password),
			redis.DialTLSConfig(clientTLSConfig),
			redis.DialUseTLS(true),
			redis.DialTLSSkipVerify(true),
		)
	}}
	c := redisearch.NewClientFromPool(pool, "search-client-1")
	sc := redisearch.NewSchema(redisearch.DefaultOptions).
		AddField(redisearch.NewTextField("body")).
		AddField(redisearch.NewTextFieldOptions("title", redisearch.TextFieldOptions{Weight: 5.0, Sortable: true})).
		AddField(redisearch.NewNumericField("date"))
	c.Drop()
	if err := c.CreateIndex(sc); err != nil {
		log.Fatal(err)
	}
	doc := redisearch.NewDocument("ExampleNewClientFromPool_ssl:doc3", 1.0)
	doc.Set("title", "Hello world").
		Set("body", "foo bar").
		Set("date", time.Now().Unix())
	if err := c.Index([]redisearch.Document{doc}...); err != nil {
		log.Fatal(err)
	}
	docs, total, err := c.Search(redisearch.NewQuery("hello world").
		Limit(0, 2).
		SetReturnFields("title"))
	fmt.Println(docs[0].Id, docs[0].Properties["title"], total, err)
}
func ExampleNewClientFromPool_ssl ( ) { host , password := getConnectionDetails ( ) tlsready , tls_cert , tls_key , tls_cacert := getTLSdetails ( ) if tlsready == false { return } cert , err := tls . LoadX509KeyPair ( tls_cert , tls_key ) if err != nil { log . Fatal ( err ) } caCert , err := ioutil . ReadFile ( tls_cacert ) if err != nil { log . Fatal ( err ) } caCertPool := x509 . NewCertPool ( ) caCertPool . AppendCertsFromPEM ( caCert ) clientTLSConfig := & tls . Config { Certificates : [ ] tls . Certificate { cert } , RootCAs : caCertPool , } clientTLSConfig . InsecureSkipVerify = true pool := & redis . Pool { Dial : func ( ) ( redis . Conn , error ) { return redis . Dial ( " " , host , redis . DialPassword ( password ) , redis . DialTLSConfig ( clientTLSConfig ) , redis . DialUseTLS ( true ) , redis . DialTLSSkipVerify ( true ) , ) } } c := redisearch . NewClientFromPool ( pool , " " ) sc := redisearch . NewSchema ( redisearch . DefaultOptions ) . AddField ( redisearch . NewTextField ( " " ) ) . AddField ( redisearch . NewTextFieldOptions ( " " , redisearch . TextFieldOptions { Weight : 5.0 , Sortable : true } ) ) . AddField ( redisearch . NewNumericField ( " " ) ) c . Drop ( ) if err := c . CreateIndex ( sc ) ; err != nil { log . Fatal ( err ) } doc := redisearch . NewDocument ( " " , 1.0 ) doc . Set ( " " , " " ) . Set ( " " , " " ) . Set ( " " , time . Now ( ) . Unix ( ) ) if err := c . Index ( [ ] redisearch . Document { doc } ... ) ; err != nil { log . Fatal ( err ) } docs , total , err := c . Search ( redisearch . NewQuery ( " " ) . Limit ( 0 , 2 ) . SetReturnFields ( " " ) ) fmt . Println ( docs [ 0 ] . Id , docs [ 0 ] . Properties [ " " ] , total , err ) }
Example of how to establish an SSL connection from your app to the RedisAI Server
Example of how to establish an SSL connection from your app to the RedisAI Server
// Consider the following helper methods that provide us with the connection details (host and password) // and the paths for: //     tls_cert - A a X.509 certificate to use for authenticating the  server to connected clients, masters or cluster peers. The file should be PEM formatted //     tls_key - A a X.509 private key to use for authenticating the  server to connected clients, masters or cluster peers. The file should be PEM formatted //	   tls_cacert - A PEM encoded CA's certificate file // Skip if we dont have all files to properly connect // Load client cert // Load CA cert // InsecureSkipVerify controls whether a client verifies the // server's certificate chain and host name. // If InsecureSkipVerify is true, TLS accepts any certificate // presented by the server and any host name in that certificate. // In this mode, TLS is susceptible to man-in-the-middle attacks. // This should be used only for testing. // Create a schema // Drop an existing index. If the index does not exist an error is returned // Create the index with the given schema // Create a document with an id and given score // Index the document. The API accepts multiple documents at a time // Searching with limit and sorting