From 78182a2d1cc6e6259876273b9135608e60f917ae Mon Sep 17 00:00:00 2001 From: Michael Chi Date: Thu, 17 Dec 2015 11:21:35 +0800 Subject: [PATCH 1/2] fix facet url --- AzureSearchTool/SearchModel.cs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/AzureSearchTool/SearchModel.cs b/AzureSearchTool/SearchModel.cs index c614840..8b8c10b 100644 --- a/AzureSearchTool/SearchModel.cs +++ b/AzureSearchTool/SearchModel.cs @@ -81,7 +81,13 @@ public string MinimumCoverage get { return _minimumCoverage; } set { _minimumCoverage = value; OnPropertyChanged("Url"); } } + private string EscapeFacet(string facet) + { + var facets = facet.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); + var url = string.Join("&facet=", facets); + return url; + } public string Url { //https://maxmelcher.search.windows.net/indexes/twittersearch/docs?search=fifa&api-version=2015-02-28&$filter=Score gt 0.5&$top=25&$count=true @@ -149,8 +155,7 @@ public string Url if (!string.IsNullOrEmpty(Facet)) { - var facet = Uri.EscapeDataString(Facet); - url += string.Format("&facet={0}", facet); + url += string.Format("&facet={0}", EscapeFacet(Facet)); } if (!string.IsNullOrEmpty(Highlight)) From cb0cbe27f5575664f122aeb5c584481bfc9b9f11 Mon Sep 17 00:00:00 2001 From: Michael Chi Date: Thu, 17 Dec 2015 17:34:02 +0800 Subject: [PATCH 2/2] add Lucene query --- AzureSearchTool/MainWindow.xaml | 110 +++++++++++++++++--------------- AzureSearchTool/SearchModel.cs | 19 ++++-- 2 files changed, 73 insertions(+), 56 deletions(-) diff --git a/AzureSearchTool/MainWindow.xaml b/AzureSearchTool/MainWindow.xaml index cfb7616..d4c1bea 100644 --- a/AzureSearchTool/MainWindow.xaml +++ b/AzureSearchTool/MainWindow.xaml @@ -212,51 +212,56 @@ - - + - - - - - - - - - - - + + + + + + + + + + + + + - - + + + + - + + - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + - - - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + + + + - + diff --git a/AzureSearchTool/SearchModel.cs b/AzureSearchTool/SearchModel.cs index 8b8c10b..c721854 100644 --- a/AzureSearchTool/SearchModel.cs +++ b/AzureSearchTool/SearchModel.cs @@ -13,9 +13,10 @@ namespace AzureSearchTool { public class SearchModel : INotifyPropertyChanged { - private string _service = "MaxMelcher"; - private string _apiKey = "B98A05BCCACF2A0BA020FE6299CD4AA1"; - + //private string _service = "MaxMelcher"; + //private string _apiKey = "B98A05BCCACF2A0BA020FE6299CD4AA1"; + private string _service = "michidemo"; + private string _apiKey = "9513E3CCC71DB6524F5A5CB153E6B0B4"; private string _apiVersion = "2015-02-28-Preview"; private const string BaseUrl = "search.windows.net"; @@ -69,7 +70,11 @@ public SearchTypes SearchType get { return _searchType; } set { _searchType = value; OnPropertyChanged("Url"); } } - + public string LuceneSearchType + { + get { return _LuceneSearchType; } + set { _LuceneSearchType = value; OnPropertyChanged("Url"); } + } public String SuggesterName { get { return _suggesterName; } @@ -200,6 +205,10 @@ public string Url url += string.Format("&fuzzy={0}", Fuzzy); } + if (!string.IsNullOrEmpty(LuceneSearchType)) + { + url += string.Format("&queryType={0}", LuceneSearchType); + } return url; } } @@ -324,7 +333,7 @@ public ObservableCollection Indexes private bool _isAdminApiKey; private bool _isQueryApiKey; private string _indexName; - + private string _LuceneSearchType; public DataTable SearchResults { get { return _searchResults; }