Repository: google/go-github

Issue:
Add `advanced_search` parameter to issue search
Currently search doesn't support [the `advanced_search` parameter](https://docs.github.com/en/rest/search/search?apiVersion=2022-11-28#search-issues-and-pull-requests) when searching issues. This can cause incorrect or no results to be returned when performing complex search queries.

For example, by default the GitHub API interprets spaces as `OR`, so the following search query returns all issues in a repository:
```
repo:org/name created:>2025-11-01 created:<=2025-11-30
```

Wrapping the dates in parentheses and explicitly defining `AND` fixes it when calling the API directly:
```
repo:org/name (created:>2025-11-01 AND created:<=2025-11-30)
```

However this is encoded in a way the default search is unable to handle, leading to no results being returned:
```
repo%3Aowner%2Fname+type%3Aissue+i%28created%3A%3E2025-11-01+AND+created%3A%3C%3D2025-11-30%29
```

This can be resolved by changing URI encoding on greater than and less than to HTML encoding:
```
repo%3Aowner%2Fname+type%3Aissue+i%28created%3A&gt;2025-11-01+AND+created%3A&lt;%3D2025-11-30%29
```

However this will likely break other functionality.

Advanced search via API was introduced by GitHub on [6 March 2025](https://github.blog/changelog/2025-03-06-github-issues-projects-api-support-for-issues-advanced-search-and-more/#mag-api-support-for-issues-advanced-search) which interprets spaces as `AND` by default and fixes the original query without the need for additional parameters. To enable advanced search functionality, `&advanced_search=true` needs to be appended to the end of the issue search URL.


Discussion:

Solution patch:
diff --git a/github/github-accessors.go b/github/github-accessors.go
index fa729b5f..63fbc951 100644
--- a/github/github-accessors.go
+++ b/github/github-accessors.go
@@ -26646,6 +26646,14 @@ func (s *SCIMUserRole) GetType() string {
 	return *s.Type
 }
 
+// GetAdvancedSearch returns the AdvancedSearch field if it's non-nil, zero value otherwise.
+func (s *SearchOptions) GetAdvancedSearch() bool {
+	if s == nil || s.AdvancedSearch == nil {
+		return false
+	}
+	return *s.AdvancedSearch
+}
+
 // GetStatus returns the Status field if it's non-nil, zero value otherwise.
 func (s *SecretScanning) GetStatus() string {
 	if s == nil || s.Status == nil {
diff --git a/github/search.go b/github/search.go
index 9b9f9370..aa99786f 100644
--- a/github/search.go
+++ b/github/search.go
@@ -54,6 +54,9 @@ type SearchOptions struct {
 	// Whether to retrieve text match metadata with a query
 	TextMatch bool `url:"-"`
 
+	// Whether to enable advanced search for issues
+	AdvancedSearch *bool `url:"advanced_search,omitempty"`
+
 	ListOptions
 }
 



Test patch:
diff --git a/github/github-accessors_test.go b/github/github-accessors_test.go
index ca457c5c..ddf09fa3 100644
--- a/github/github-accessors_test.go
+++ b/github/github-accessors_test.go
@@ -34393,6 +34393,17 @@ func TestSCIMUserRole_GetType(tt *testing.T) {
 	s.GetType()
 }
 
+func TestSearchOptions_GetAdvancedSearch(tt *testing.T) {
+	tt.Parallel()
+	var zeroValue bool
+	s := &SearchOptions{AdvancedSearch: &zeroValue}
+	s.GetAdvancedSearch()
+	s = &SearchOptions{}
+	s.GetAdvancedSearch()
+	s = nil
+	s.GetAdvancedSearch()
+}
+
 func TestSecretScanning_GetStatus(tt *testing.T) {
 	tt.Parallel()
 	var zeroValue string
diff --git a/github/search_test.go b/github/search_test.go
index aec5b56c..91a2bab4 100644
--- a/github/search_test.go
+++ b/github/search_test.go
@@ -265,6 +265,41 @@ func TestSearchService_Issues(t *testing.T) {
 	}
 }
 
+func TestSearchService_Issues_advancedSearch(t *testing.T) {
+	t.Parallel()
+	client, mux, _ := setup(t)
+
+	mux.HandleFunc("/search/issues", func(w http.ResponseWriter, r *http.Request) {
+		testMethod(t, r, "GET")
+		testFormValues(t, r, values{
+			"q":               "blah",
+			"sort":            "forks",
+			"order":           "desc",
+			"page":            "2",
+			"per_page":        "2",
+			"advanced_search": "true",
+		})
+
+		fmt.Fprint(w, `{"total_count": 4, "incomplete_results": true, "items": [{"number":1},{"number":2}]}`)
+	})
+
+	opts := &SearchOptions{Sort: "forks", Order: "desc", ListOptions: ListOptions{Page: 2, PerPage: 2}, AdvancedSearch: Ptr(true)}
+	ctx := t.Context()
+	result, _, err := client.Search.Issues(ctx, "blah", opts)
+	if err != nil {
+		t.Errorf("Search.Issues_advancedSearch returned error: %v", err)
+	}
+
+	want := &IssuesSearchResult{
+		Total:             Ptr(4),
+		IncompleteResults: Ptr(true),
+		Issues:            []*Issue{{Number: Ptr(1)}, {Number: Ptr(2)}},
+	}
+	if !cmp.Equal(result, want) {
+		t.Errorf("Search.Issues_advancedSearch returned %+v, want %+v", result, want)
+	}
+}
+
 func TestSearchService_Issues_coverage(t *testing.T) {
 	t.Parallel()
 	client, _, _ := setup(t)