Skip to content

Commit fc1b74a

Browse files
authored
Expose q querystring parameter on search (#4238)
* remove q from block list on SearchOverrides * Expose ?q as QueryOnQueryString for search like its exposed on other API's as well' * eventhough we expose q on query string it should not trigger GET as we always end up sending other params in the body
1 parent 88e5c40 commit fc1b74a

File tree

5 files changed

+19
-4
lines changed

5 files changed

+19
-4
lines changed

src/CodeGeneration/ApiGenerator/Configuration/Overrides/Endpoints/SearchOverrides.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ public class SearchOverrides : EndpointOverridesBase
1212
"timeout",
1313
"explain",
1414
"version",
15-
"q", //we dont support GET searches
1615
"sort",
1716
"_source",
1817
"_source_includes",

src/Elasticsearch.Net/Api/RequestParameters/RequestParameters.NoNamespace.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1660,6 +1660,13 @@ public string Preference
16601660
set => Q("preference", value);
16611661
}
16621662

1663+
///<summary>Query in the Lucene query string syntax</summary>
1664+
public string QueryOnQueryString
1665+
{
1666+
get => Q<string>("q");
1667+
set => Q("q", value);
1668+
}
1669+
16631670
///<summary>Specify if request cache should be used for this request or not, defaults to index level setting</summary>
16641671
public bool? RequestCache
16651672
{

src/Nest/Descriptors.NoNamespace.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1278,6 +1278,8 @@ public SearchDescriptor<TInferDocument> Index<TOther>()
12781278
public SearchDescriptor<TInferDocument> PreFilterShardSize(long? prefiltershardsize) => Qs("pre_filter_shard_size", prefiltershardsize);
12791279
///<summary>Specify the node or shard the operation should be performed on (default: random)</summary>
12801280
public SearchDescriptor<TInferDocument> Preference(string preference) => Qs("preference", preference);
1281+
///<summary>Query in the Lucene query string syntax</summary>
1282+
public SearchDescriptor<TInferDocument> QueryOnQueryString(string queryonquerystring) => Qs("q", queryonquerystring);
12811283
///<summary>Specify if request cache should be used for this request or not, defaults to index level setting</summary>
12821284
public SearchDescriptor<TInferDocument> RequestCache(bool? requestcache = true) => Qs("request_cache", requestcache);
12831285
///<summary>

src/Nest/Requests.NoNamespace.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2744,6 +2744,13 @@ public string Preference
27442744
set => Q("preference", value);
27452745
}
27462746

2747+
///<summary>Query in the Lucene query string syntax</summary>
2748+
public string QueryOnQueryString
2749+
{
2750+
get => Q<string>("q");
2751+
set => Q("q", value);
2752+
}
2753+
27472754
///<summary>Specify if request cache should be used for this request or not, defaults to index level setting</summary>
27482755
public bool? RequestCache
27492756
{

src/Nest/Search/Search/SearchRequest.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ public partial interface ISearchRequest : ITypedSearchRequest
155155
/// </summary>
156156
[DataMember(Name = "track_scores")]
157157
bool? TrackScores { get; set; }
158-
158+
159159
/// <summary>
160160
/// Return a version for each search hit
161161
/// </summary>
@@ -224,7 +224,7 @@ public partial class SearchRequest
224224
public bool? Version { get; set; }
225225

226226
protected override HttpMethod HttpMethod =>
227-
RequestState.RequestParameters?.ContainsQueryString("source") == true || RequestState.RequestParameters?.ContainsQueryString("q") == true
227+
RequestState.RequestParameters?.ContainsQueryString("source") == true
228228
? HttpMethod.GET
229229
: HttpMethod.POST;
230230

@@ -246,7 +246,7 @@ public partial class SearchRequest<TInferDocument> : ISearchRequest<TInferDocume
246246
public partial class SearchDescriptor<TInferDocument> where TInferDocument : class
247247
{
248248
protected override HttpMethod HttpMethod =>
249-
RequestState.RequestParameters?.ContainsQueryString("source") == true || RequestState.RequestParameters?.ContainsQueryString("q") == true
249+
RequestState.RequestParameters?.ContainsQueryString("source") == true
250250
? HttpMethod.GET
251251
: HttpMethod.POST;
252252

0 commit comments

Comments
 (0)