# Null result in NewSimpleQueryStringQuery() with Golang

**URL:** <https://discuss.elastic.co/t/null-result-in-newsimplequerystringquery-with-golang/204796>\
**Category:** Elasticsearch\
**Created:** [October 23, 2019, 7:07am UTC](https://discuss.elastic.co/t/null-result-in-newsimplequerystringquery-with-golang/204796 "2019-10-23T07:07:23Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mehrdad.dev](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mehrdad.dev/32/56326_2.png) [@Mehrdad.dev](https://discuss.elastic.co/u/Mehrdad.dev)\
**Post date:** [October 23, 2019, 7:07am UTC](https://discuss.elastic.co/t/null-result-in-newsimplequerystringquery-with-golang/204796/1 "2019-10-23T07:07:24Z")

</div>

Hi.  
I want search a query string with NewSimpleQueryStringQuery() function.

my code is :

```
func Search(ctx context.Context, client *elastic.Client, index string) {
	var companies []People
	q := `{
		"query": {
		  "simple_query_string" : {
			"query": "mahmood rahimi",
			"fields": ["Firstname", "Lastname"] 
		  }
		}
	}`
	result := elastic.NewSimpleQueryStringQuery(q)
	searchResult, err := client.Search().
		Index(index).
		// Type("article").
		Query(result).
		Do(ctx)
	if err != nil {
		fmt.Println(err)
	}`

	for _, hit := range searchResult.Hits.Hits {
		var cmp People
		fmt.Println(hit.Source)
		err := json.Unmarshal(hit.Source, &cmp)
		if err != nil {
			fmt.Println(err)
		}
		fmt.Println(cmp)
		companies = append(companies, cmp)
	}
	fmt.Println(companies)
}

```

But the result printing companies in null.

**Can you help me ?**

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [November 20, 2019, 7:07am UTC](https://discuss.elastic.co/t/null-result-in-newsimplequerystringquery-with-golang/204796/2 "2019-11-20T07:07:29Z")

</div>

Closed on November 20, 2019, 7:07am UTC

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
