Skip to content

Commit

Permalink
Add support for interleaving, and default to false.
Browse files Browse the repository at this point in the history
  • Loading branch information
wobba committed Oct 21, 2022
1 parent dc04d60 commit c8e858e
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:Themes="clr-namespace:Microsoft.Windows.Themes;assembly=PresentationFramework.Classic" x:Class="SearchQueryTool.MainWindow"
Icon="Images/sp_site.png"
Title="SharePoint Search Query Tool v2.9.1" Height="820" Width="1120" MinWidth="800" MinHeight="600">
Title="SharePoint Search Query Tool v2.10.0" Height="820" Width="1120" MinWidth="800" MinHeight="600">
<Window.Resources>
<DrawingImage x:Key="Overlay">
<DrawingImage.Drawing>
Expand Down Expand Up @@ -257,6 +257,23 @@
ToolTip="Enable Query Rules" Content="Enable Query Rules"/>
</Grid>

<Rectangle Height="5" />
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="2.2*"/>
<ColumnDefinition Width="1*"/>
</Grid.ColumnDefinitions>
<CheckBox x:Name="EnableInterleavingCheckBox"
DataContext="EnableInterleaving"
IsChecked="{x:Null}"
Unchecked="SearchQueryCheckBox_CheckChanged"
Checked="SearchQueryCheckBox_CheckChanged" Content="Enable Interleaving">
<CheckBox.ToolTip>
<TextBlock><Run Text="Specifies whether query rule result blocks can be interleaved or not in the response"/></TextBlock>
</CheckBox.ToolTip>
</CheckBox>
</Grid>

<Rectangle Height="5" />

<Grid>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -668,6 +668,9 @@ private void SearchQueryCheckBox_CheckChanged(object sender, RoutedEventArgs e)
case "enablenicknames":
_searchQueryRequest.EnableNicknames = cb.IsChecked;
break;
case "enableinterleaving":
_searchQueryRequest.EnableInterleaving = cb.IsChecked;
break;
case "processbestbets":
_searchQueryRequest.ProcessBestBets = cb.IsChecked;
break;
Expand Down Expand Up @@ -722,6 +725,9 @@ private void ResetCheckboxesButton_Click(object sender, RoutedEventArgs e)
_searchQueryRequest.EnableQueryRules = null;
EnableQueryRulesCheckBox.IsChecked = null;

_searchQueryRequest.EnableInterleaving = null;
EnableInterleavingCheckBox.IsChecked = null;

_searchQueryRequest.EnableNicknames = null;
EnableNicknamesCheckBox.IsChecked = null;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public class SearchQueryRequest : SearchRequest
public bool? TrimDuplicates { get; set; }
public bool? EnableFql { get; set; }
public bool? EnableQueryRules { get; set; }
public bool? EnableInterleaving { get; set; }
public bool? ProcessBestBets { get; set; }
public bool? ByPassResultTypes { get; set; }
public bool? ProcessPersonalFavorites { get; set; }
Expand Down Expand Up @@ -67,7 +68,7 @@ public override string GenerateHttpGetUri()
uriBuilder.Append("/");
}

uriBuilder.AppendFormat("_api/search/query?querytext='{0}'", UrlEncode(this.QueryText?.Replace("'","''")));
uriBuilder.AppendFormat("_api/search/query?querytext='{0}'", UrlEncode(this.QueryText?.Replace("'", "''")));

if (this.EnableStemming == true)
uriBuilder.Append("&enablestemming=true");
Expand Down Expand Up @@ -99,6 +100,11 @@ public override string GenerateHttpGetUri()
else if (this.EnableQueryRules == false)
uriBuilder.Append("&enablequeryrules=false");

if (this.EnableInterleaving == true)
uriBuilder.Append("&enableinterleaving=true");
else if (this.EnableInterleaving == false || (this.EnableInterleaving == null && (this.EnableQueryRules == null || this.EnableQueryRules == true)))
uriBuilder.Append("&enableinterleaving=false");

if (this.ProcessBestBets == true)
uriBuilder.Append("&processbestbets=true");
else if (this.ProcessBestBets == false)
Expand Down Expand Up @@ -286,9 +292,9 @@ public override string GenerateHttpPostUri()
public override string GenerateHttpPostBodyPayload()
{
StringBuilder searchRequestBuilder = new StringBuilder();
List<string> customPropertyParts = new List<string>();
List<string> customPropertyParts = new List<string>();

searchRequestBuilder.AppendFormat("{{'request': {{ 'Querytext':'{0}'", this.QueryText?.Replace("'","\\'"));
searchRequestBuilder.AppendFormat("{{'request': {{ 'Querytext':'{0}'", this.QueryText?.Replace("'", "\\'"));

if (this.EnableStemming == true)
searchRequestBuilder.Append(", 'EnableStemming':true");
Expand Down Expand Up @@ -330,6 +336,11 @@ public override string GenerateHttpPostBodyPayload()
else if (this.EnableQueryRules == false)
searchRequestBuilder.Append(", 'EnableQueryRules':false");

if (this.EnableInterleaving == true)
searchRequestBuilder.Append(", 'EnableInterleaving':true");
else if (this.EnableInterleaving == false || (this.EnableInterleaving == null && (this.EnableQueryRules == null || this.EnableQueryRules == true)))
searchRequestBuilder.Append(", 'EnableInterleaving':false");

if (this.ProcessPersonalFavorites == true)
searchRequestBuilder.Append(", 'ProcessPersonalFavorites':true");
else if (this.ProcessPersonalFavorites == false)
Expand Down

0 comments on commit c8e858e

Please sign in to comment.