# Go Client: nearText returns nothing. GraphQL does

**URL:** <https://forum.weaviate.io/t/go-client-neartext-returns-nothing-graphql-does/373>\
**Category:** Support\
**Created:** [July 16, 2023, 12:46am UTC](https://forum.weaviate.io/t/go-client-neartext-returns-nothing-graphql-does/373 "2023-07-16T00:46:50Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![chriscow](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.weaviate.io/chriscow/32/280_2.png) [@chriscow](https://forum.weaviate.io/u/chriscow)\
**Post date:** [July 16, 2023, 12:46am UTC](https://forum.weaviate.io/t/go-client-neartext-returns-nothing-graphql-does/373/1 "2023-07-16T00:46:50Z")

</div>

I’m having trouble with the Go client and nearText returning no results. I’ve tried the same query in the Weaviate Console (GraphQL) as well as the Python client. Both of these work fine but when I try the same with the Go client I get no results.

If I eliminate the nearText constraint with the Go client, all results are returned so I know it is connecting.

This is my GraphQL query:

```json
{
  Get {
    Takeaway (nearText: {concepts: ["Importance of Effective Radio Communications"]} ) {
      title
    }
  }
}

```

This Go code without the nearText works:

```go
package main

import (
	"context"
	"fmt"

	"github.com/weaviate/weaviate-go-client/v4/weaviate"
	"github.com/weaviate/weaviate-go-client/v4/weaviate/graphql"
)

func main() {
	cfg := weaviate.Config{
		Host: "weaviate:8080",
		Scheme: "http",
	}
	client, err := weaviate.NewClient(cfg)
	if err != nil {
		panic(err)
	}

	className := "Takeaway"

	title := graphql.Field{Name: "title"}

	ctx := context.Background()

	result, err := client.GraphQL().Get().
		WithClassName(className).
		WithFields(title).
		Do(ctx)

	if err != nil {
		panic(err)
	}
	fmt.Printf("%v", result)
}

```

Adding the nearText constraint returns no records:

```go
package main

import (
	"context"
	"fmt"

	"github.com/weaviate/weaviate-go-client/v4/weaviate"
	"github.com/weaviate/weaviate-go-client/v4/weaviate/graphql"
)

func main() {
	cfg := weaviate.Config{
		Host: "weaviate:8080",
		Scheme: "http",
	}
	client, err := weaviate.NewClient(cfg)
	if err != nil {
		panic(err)
	}

	className := "Takeaway"

	title := graphql.Field{Name: "title"}

	concepts := []string{"Importance of Effective Radio Communications"}

	nearText := client.GraphQL().NearTextArgBuilder().
		WithConcepts(concepts)

	ctx := context.Background()

	result, err := client.GraphQL().Get().
		WithClassName(className).
		WithFields(title).
		WithNearText(nearText).
		Do(ctx)

	if err != nil {
		panic(err)
	}
	fmt.Printf("%v", result)
}

```

I’m sure I’m missing something obvious but I can’t figure it out. Any help is appreciated. Thx!

---

<div class="post-metadata">

**Author:** ![chriscow](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.weaviate.io/chriscow/32/280_2.png) [@chriscow](https://forum.weaviate.io/u/chriscow)\
**Post date:** [July 16, 2023, 11:14pm UTC](https://forum.weaviate.io/t/go-client-neartext-returns-nothing-graphql-does/373/2 "2023-07-16T23:14:50Z")

</div>

The problem, it turns out, that I need to add the `X-Openai-Api-Key` to the `weaviate.Config`

I missed that detail that I had added in my Python implementation but not in my Go implementation.

In Go, with `result, err := client.GraphQL().Get() ...` even though the `result,` contains a map with `Errors`, I didn’t know to check that. I expected the error to show up in the err return value. 👎

When I simply printed with `fmt.Printf("%v", result)`, the whole GraphQLResponse object is not printed. Whatever. Moving on. Hope this helps someone.

Correctly configuring the Weaviate client for OpenAI in my case:

```go
	cfg := weaviate.Config{
		Host: "weaviate:8080",
		Scheme: "http",
		Headers: map[string]string{
			"X-Openai-Api-Key": "OPENAI_API_KEY HERE",
		},
	}

```

---

<div class="post-metadata">

**Author:** ![jphwang](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.weaviate.io/jphwang/32/38_2.png) [@jphwang](https://forum.weaviate.io/u/jphwang)\
**Post date:** [July 17, 2023, 9:07am UTC](https://forum.weaviate.io/t/go-client-neartext-returns-nothing-graphql-does/373/3 "2023-07-17T09:07:07Z")

</div>

Hi @chriscow - I’m glad you were able to diagnose the error. I’ll pass on the feedback about the error locations - I appreciate that it can be unintuitive.

Cheers,  
JP
