Exemplo n.º 1
0
        public ActionResult Both(string term)
        {
            InitSearch();

            AutocompleteParameters sp1 = new AutocompleteParameters()
            {
                AutocompleteMode = AutocompleteMode.OneTermWithContext,
                UseFuzzyMatching = false,
                Top             = 5,
                MinimumCoverage = 80
            };
            AutocompleteResult resp1 = _indexClient.Documents.Autocomplete(term, "sg", sp1);

            // Call both the suggest and autocomplete API and return results
            SuggestParameters sp2 = new SuggestParameters()
            {
                UseFuzzyMatching = false,
                Top = 5
            };
            DocumentSuggestResult resp2 = _indexClient.Documents.Suggest(term, "sg", sp2);

            //Convert the suggest query results to a list that can be displayed in the client.
            var result = resp1.Results.Select(x => new { label = x.Text, category = "Autocomplete" }).ToList();

            result.AddRange(resp2.Results.Select(x => new { label = x.Text, category = "Suggestions" }).ToList());

            return(new JsonResult
            {
                JsonRequestBehavior = JsonRequestBehavior.AllowGet,
                Data = result
            });
        }
Exemplo n.º 2
0
        public List <string> GetSearchAutocomplete(string text)
        {
            if (string.IsNullOrEmpty(text))
            {
                return(new List <string>());
            }
            try
            {
                bool isFuzzyEnabled = false, isHiglightsEnabled = false;

                AutocompleteParameters ap = new AutocompleteParameters()
                {
                    AutocompleteMode = AutocompleteMode.OneTermWithContext,
                    UseFuzzyMatching = isFuzzyEnabled,
                    Top = 5
                };
                AutocompleteResult autocompleteResult = IndexClientSearch.Documents.Autocomplete(text, "toksdev-suggest", ap);

                // Convert the suggest query results to a list that can be displayed in the client.
                List <string> suggestions = (autocompleteResult.Results.Select(x => x.Text)).Distinct().ToList();
                return(suggestions);
            }
            catch (Exception e)
            {
                return(new List <string>());
            }
        }
Exemplo n.º 3
0
        private static void RunAutocompleteQueries(ISearchIndexClient indexClient)
        {
            AutocompleteParameters acparameters = new AutocompleteParameters
            {
                SearchFields = "hotelName,description"
            };

            Console.WriteLine("Autocomplete query with OneTerm mode:\n");

            AutocompleteResult response = indexClient.Documents.Autocomplete(AutocompleteMode.OneTerm, "best ho", "sg", autocompleteParameters: acparameters);

            WriteAutocompleteResults(response);

            Console.WriteLine("Autocomplete with OneTermWithContext mode:\n");

            response = indexClient.Documents.Autocomplete(AutocompleteMode.OneTermWithContext, "best ho", "sg", autocompleteParameters: acparameters);

            WriteAutocompleteResults(response);

            Console.WriteLine("Autocomplete with TwoTerms mode:\n");

            response = indexClient.Documents.Autocomplete(AutocompleteMode.TwoTerms, "best ho", "sg", autocompleteParameters: acparameters);

            WriteAutocompleteResults(response);

            Console.WriteLine("Autocomplete with OneTerm mode with fuzzy enabled:\n");

            acparameters.Fuzzy = true;
            response           = indexClient.Documents.Autocomplete(AutocompleteMode.OneTerm, "best hostel", "sg", autocompleteParameters: acparameters);

            WriteAutocompleteResults(response);
        }
        public async Task <string> SearchCity(string input)
        {
            var        ulrRequest = $@"https://maps.googleapis.com/maps/api/place/autocomplete/json?input={input}&types=(regions)&language=fr&components=country:fr&radius=50000&key=AIzaSyDtDGjLnw-S73R1l2VcS-5mKZi42R9JXkE";
            HttpClient httpcli    = new HttpClient();
            var        result     = await httpcli.GetStringAsync(ulrRequest);

            AutocompleteResult pocoResult = JsonConvert.DeserializeObject <AutocompleteResult>(result);

            if (pocoResult.predictions.Count > 0)
            {
                var primary            = pocoResult.predictions[0];
                var searchEpicentreUrl = $@"https://maps.googleapis.com/maps/api/place/details/json?placeid={primary.place_id}&key=AIzaSyC6brf9Bm7PBSXGzDwg2_lD10c-JAMspHo";
                var jsonplace          = await httpcli.GetStringAsync(searchEpicentreUrl);

                var poco = JsonConvert.DeserializeObject <PlacesResult>(jsonplace);
                //var detailedurl = $@"https://maps.googleapis.com/maps/api/place/autocomplete/json?input={input}&types=(regions)&language=fr&components=country:fr&radius=10000&location={poco.result.geometry.location.lat},{poco.result.geometry.location.lng}&key=AIzaSyDtDGjLnw-S73R1l2VcS-5mKZi42R9JXkE";
                //result = await httpcli.GetStringAsync(detailedurl);
                //pocoResult = JsonConvert.DeserializeObject<AutocompleteResult>(result);

                var geocodeurl    = $@"http://api.geonames.org/findNearbyPlaceNameJSON?lat={poco.result.geometry.location.lat}&lng={poco.result.geometry.location.lng}&style=short&cities=cities5000&radius=30&maxRows=30&username=centuryspine";
                var geocodenearby = await httpcli.GetStringAsync(geocodeurl);

                return /*Json(*/ (geocodenearby /*, JsonRequestBehavior.AllowGet)*/);
            }

            return /*Json(*/ (result /*, JsonRequestBehavior.AllowGet)*/);
        }
Exemplo n.º 5
0
        public async Task <IActionResult> Autocomplete([FromQuery(Name = "q")] string query = null)
        {
            var results = await _searchService.AutocompleteAsync(query);

            var response = new AutocompleteResult(results.Count, results);

            return(Json(response));
        }
Exemplo n.º 6
0
        protected void TestAutocompleteFuzzyIsOffByDefault()
        {
            SearchIndexClient client   = GetClientForQuery();
            var autocompleteParameters = new AutocompleteParameters()
            {
                AutocompleteMode = AutocompleteMode.OneTerm
            };

            AutocompleteResult response = client.Documents.Autocomplete("pi", "sg", autocompleteParameters);

            Assert.NotNull(response.Results);
            Assert.Equal(0, response.Results.Count);
        }
Exemplo n.º 7
0
        protected void TestAutocompleteExcludesFieldsNotInSuggester()
        {
            SearchIndexClient client   = GetClientForQuery();
            var autocompleteParameters = new AutocompleteParameters()
            {
                AutocompleteMode = AutocompleteMode.OneTerm,
                SearchFields     = new[] { "hotelName" }
            };
            AutocompleteResult response = client.Documents.Autocomplete("luxu", "sg", autocompleteParameters);

            Assert.NotNull(response);
            Assert.NotNull(response.Results);
            Assert.Equal(0, response.Results.Count);
        }
Exemplo n.º 8
0
 private static void WriteAutocompleteResults(AutocompleteResult autocompleteResponse)
 {
     if (autocompleteResponse.Results.Count != 0)
     {
         foreach (AutocompleteItem item in autocompleteResponse.Results)
         {
             Console.WriteLine("text: " + item.Text + " queryPlusText: " + item.QueryPlusText);
         }
     }
     else
     {
         Console.WriteLine("no text matched");
     }
     Console.WriteLine();
 }
Exemplo n.º 9
0
        public ActionResult GetAutocomplete(string query)
        {
            AutocompleteResult tResult = new AutocompleteResult();
            var tempresult             = new DemoBll().GetDepartmentList();
            var temp = (from a in tempresult
                        where a.DepartpmentName.Contains(query)
                        select new AutocompleteEntity
            {
                value = a.DepartpmentName,
                data = a.DepartpmentId
            }).ToList();

            tResult.suggestions = temp;
            tResult.query       = query;
            return(ToJsonResult(tResult));
        }
Exemplo n.º 10
0
        public async Task <ActionResult> AutoComplete(string term)
        {
            InitSearch();

            // Setup the autocomplete parameters.
            var ap = new AutocompleteParameters()
            {
                AutocompleteMode = AutocompleteMode.OneTermWithContext,
                Top = 6
            };
            AutocompleteResult autocompleteResult = await _indexClient.Documents.AutocompleteAsync(term, "sg", ap);

            // Convert the autocompleteResult results to a list that can be displayed in the client.
            List <string> autocomplete = autocompleteResult.Results.Select(x => x.Text).ToList();

            return(new JsonResult(autocomplete));
        }
Exemplo n.º 11
0
        public static async Task <AutocompleteResult> GetAutoCompleteAsync(string query)
        {
            var result = new AutocompleteResult();

            var url = string.Format(BASE_URL_AUTOCOMPLETE, query, AUTO_COMPLETE_API_KEY);

            using (HttpClient client = new HttpClient())
            {
                var response = await client.GetAsync(url);

                var json = await response.Content.ReadAsStringAsync();

                result = JsonConvert.DeserializeObject <AutocompleteResult>(json);
            }

            return(result);
        }
Exemplo n.º 12
0
        public IActionResult Autocomplete(string term)
        {
            InitSearch();
            //Call autocomplete API and return results
            AutocompleteParameters ap = new AutocompleteParameters()
            {
                AutocompleteMode = AutocompleteMode.OneTermWithContext,
                UseFuzzyMatching = false,
                Top = 5
            };
            AutocompleteResult autocompleteResult = _indexClient.Documents.Autocomplete(term, "sg", ap);

            // Conver the Suggest results to a list that can be displayed in the client.
            List <string> autocomplete = autocompleteResult.Results.Select(x => x.Text).ToList();

            return(new JsonResult(autocomplete.ToArray()));
        }
Exemplo n.º 13
0
        public async Task <ActionResult> AutoCompleteAndSuggest(string term)
        {
            // Use static variables to set up the configuration and Azure service and index clients, for efficiency.
            _builder       = new ConfigurationBuilder().AddJsonFile("appsettings.json");
            _configuration = _builder.Build();

            _serviceClient = CreateSearchServiceClient(_configuration);
            _indexClient   = _serviceClient.Indexes.GetClient("hotels");

            //Call autocomplete API and return results
            AutocompleteParameters ap = new AutocompleteParameters()
            {
                AutocompleteMode = AutocompleteMode.OneTermWithContext,
                UseFuzzyMatching = false,
                Top = 1,
            };
            AutocompleteResult autocompleteResult = await _indexClient.Documents.AutocompleteAsync(term, "sg", ap);

            // Call suggest API and return results
            SuggestParameters sp = new SuggestParameters()
            {
                UseFuzzyMatching = false,
                Top = 8,
            };

            // Only one suggester can be specified per index. The name of the suggester is set when the suggester is specified by other API calls.
            // The suggester for the hotel database is called "sg" and simply searches the hotel name.
            DocumentSuggestResult <Hotel> suggestResult = await _indexClient.Documents.SuggestAsync <Hotel>(term, "sg", sp);

            List <string> results = new List <string>();

            if (autocompleteResult.Results.Count > 0)
            {
                results.Add(autocompleteResult.Results[0].Text);
            }
            else
            {
                results.Add("");
            }
            for (int n = 0; n < suggestResult.Results.Count; n++)
            {
                results.Add(suggestResult.Results[n].Text);
            }
            return(new JsonResult((object)results));
        }
Exemplo n.º 14
0
        protected void TestAutocompleteDefaultsToOneTermMode()
        {
            var expectedText = new List <string>()
            {
                "point", "police", "polite", "pool", "popular"
            };
            var expectedQueryPlusText = new List <string>()
            {
                "point", "police", "polite", "pool", "popular"
            };

            SearchIndexClient client = GetClientForQuery();

            AutocompleteResult response = client.Documents.Autocomplete("po", "sg");

            Assert.NotNull(response);
            ValidateResults(response.Results, expectedText, expectedQueryPlusText);
        }
        public ActionResult AutoComplete(string request = "")
        {
            if (string.IsNullOrEmpty(request))
            {
                return(new JsonResult(""));
            }
            AutocompleteResult autocompleteResult = _docSearch.AutoComplete(request);
            // Conver the Suggest results to a list that can be displayed in the client.
            List <string> autocomplete = autocompleteResult.Results.Select(x => x.Text).ToList();

            if (autocomplete == null)
            {
                return(new JsonResult(""));
            }
            JsonResult res = new  JsonResult(autocomplete);

            return(res);
        }
Exemplo n.º 16
0
        public async Task <ActionResult> AutocompleteAndSuggest(string term)
        {
            InitSearch();

            // Setup the type-ahead search parameters.
            var ap = new AutocompleteParameters()
            {
                AutocompleteMode = AutocompleteMode.OneTermWithContext,
                Top = 1,
            };
            AutocompleteResult autocompleteResult = await _indexClient.Documents.AutocompleteAsync(term, "sg", ap);

            // Setup the suggest search parameters.
            var sp = new SuggestParameters()
            {
                Top = 8,
            };

            // Only one suggester can be specified per index. The name of the suggester is set when the suggester is specified by other API calls.
            // The suggester for the hotel database is called "sg" and simply searches the hotel name.
            DocumentSuggestResult <Hotel> suggestResult = await _indexClient.Documents.SuggestAsync <Hotel>(term, "sg", sp);

            // Create an empty list.
            var results = new List <string>();

            if (autocompleteResult.Results.Count > 0)
            {
                // Add the top result for type-ahead.
                results.Add(autocompleteResult.Results[0].Text);
            }
            else
            {
                // There were no type-ahead suggestions, so add an empty string.
                results.Add("");
            }
            for (int n = 0; n < suggestResult.Results.Count; n++)
            {
                // Now add the suggestions.
                results.Add(suggestResult.Results[n].Text);
            }

            // Return the list.
            return(new JsonResult(results));
        }
Exemplo n.º 17
0
        public async Task <ActionResult> AutocompleteAndSuggest(string term)
        {
            InitSearch();

            // Setup the type-ahead search parameters.
            var ap = new AutocompleteParameters
            {
                AutocompleteMode = AutocompleteMode.OneTermWithContext,
                Top = 1
            };
            AutocompleteResult autocompleteResult = await _indexClient.Documents.AutocompleteAsync(term, "sg", ap);

            // Setup the suggest search parameters.
            var sp = new SuggestParameters
            {
                Top = 8
            };

            DocumentSuggestResult <Hotel> suggestResult =
                await _indexClient.Documents.SuggestAsync <Hotel>(term, "sg", sp);

            var results = new List <string>();

            if (autocompleteResult.Results.Count > 0)
            {
                // Add the top result for type-ahead
                results.Add(autocompleteResult.Results[0].Text);
            }
            else
            {
                // There were no type-ahead suggestions, so add an empty string.
                results.Add(string.Empty);
            }

            foreach (var result in suggestResult.Results)
            {
                results.Add(result.Text);
            }

            return(new JsonResult(results));
        }
Exemplo n.º 18
0
        protected void TestAutocompleteStaticallyTypedDocuments()
        {
            var expectedText = new List <string>()
            {
                "point", "police", "polite", "pool", "popular"
            };
            var expectedQueryPlusText = new List <string>()
            {
                "very point", "very police", "very polite", "very pool", "very popular"
            };

            SearchIndexClient client = GetClientForQuery();

            var autocompleteParameters = new AutocompleteParameters()
            {
                AutocompleteMode = AutocompleteMode.OneTerm, UseFuzzyMatching = false
            };
            AutocompleteResult response = client.Documents.Autocomplete("very po", "sg", autocompleteParameters);

            ValidateResults(response.Results, expectedText, expectedQueryPlusText);
        }
Exemplo n.º 19
0
        protected void TestAutocompleteOneTermWithContextWithFuzzy()
        {
            var expectedText = new List <string>()
            {
                "very polite", "very police"
            };
            var expectedQueryPlusText = new List <string>()
            {
                "very polite", "very police"
            };

            SearchIndexClient client   = GetClientForQuery();
            var autocompleteParameters = new AutocompleteParameters()
            {
                AutocompleteMode = AutocompleteMode.OneTermWithContext, UseFuzzyMatching = true
            };
            AutocompleteResult response = client.Documents.Autocomplete("very polit", "sg", autocompleteParameters);

            Assert.NotNull(response);
            ValidateResults(response.Results, expectedText, expectedQueryPlusText);
        }
Exemplo n.º 20
0
        protected void TestAutocompleteTwoTermsWithFuzzy()
        {
            var expectedText = new List <string>()
            {
                "model suites", "modern architecture", "modern stay", "morel coverings", "motel"
            };
            var expectedQueryPlusText = new List <string>()
            {
                "model suites", "modern architecture", "modern stay", "morel coverings", "motel"
            };

            SearchIndexClient client   = GetClientForQuery();
            var autocompleteParameters = new AutocompleteParameters()
            {
                AutocompleteMode = AutocompleteMode.TwoTerms, UseFuzzyMatching = true
            };
            AutocompleteResult response = client.Documents.Autocomplete("mod", "sg", autocompleteParameters);

            Assert.NotNull(response);
            ValidateResults(response.Results, expectedText, expectedQueryPlusText);
        }
Exemplo n.º 21
0
        protected void TestAutocompleteWithMultipleSelectedFields()
        {
            var expectedText = new List <string>()
            {
                "model", "modern"
            };
            var expectedQueryPlusText = new List <string>()
            {
                "model", "modern"
            };

            SearchIndexClient client   = GetClientForQuery();
            var autocompleteParameters = new AutocompleteParameters()
            {
                AutocompleteMode = AutocompleteMode.OneTerm,
                SearchFields     = new[] { "hotelName", "description" }
            };
            AutocompleteResult response = client.Documents.Autocomplete("mod", "sg", autocompleteParameters);

            Assert.NotNull(response);
            ValidateResults(response.Results, expectedText, expectedQueryPlusText);
        }
Exemplo n.º 22
0
        protected void TestAutocompleteOneTerm()
        {
            var expectedText = new List <string>()
            {
                "point", "police", "polite", "pool", "popular"
            };
            var expectedQueryPlusText = new List <string>()
            {
                "point", "police", "polite", "pool", "popular"
            };

            SearchIndexClient client   = GetClientForQuery();
            var autocompleteParameters = new AutocompleteParameters()
            {
                AutocompleteMode = AutocompleteMode.OneTerm
            };

            AutocompleteResult response = client.Documents.Autocomplete("po", "sg", autocompleteParameters);

            Assert.NotNull(response);
            ValidateResults(response.Results, expectedText, expectedQueryPlusText);
        }
Exemplo n.º 23
0
        public ActionResult AutoComplete(string term)
        {
            InitSearch();
            //Call autocomplete API and return results
            AutocompleteParameters sp = new AutocompleteParameters()
            {
                AutocompleteMode = AutocompleteMode.OneTermWithContext,
                UseFuzzyMatching = false,
                Top             = 5,
                MinimumCoverage = 80
            };
            AutocompleteResult resp = _indexClient.Documents.Autocomplete(term, "sg", sp);

            // Conver the Suggest results to a list that can be displayed in the client.
            List <string> autocomplete = resp.Results.Select(x => x.Text).ToList();

            return(new JsonResult
            {
                JsonRequestBehavior = JsonRequestBehavior.AllowGet,
                Data = autocomplete
            });
        }
Exemplo n.º 24
0
        public AutocompleteResult AutoComplete(string searchText)
        {
            try
            {
                AutocompleteParameters ap = new AutocompleteParameters()
                {
                    AutocompleteMode = AutocompleteMode.OneTermWithContext,
                    UseFuzzyMatching = true,
                    HighlightPreTag  = "<b >",
                    HighlightPostTag = "</b>",
                    Top = 5
                };

                AutocompleteResult autocompleteResult = _indexClient.Documents.Autocomplete(searchText, "AccountSuggester", ap);
                return(autocompleteResult);
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error querying index: {0}\r\n", ex.Message.ToString( ));
            }
            return(null);
        }
Exemplo n.º 25
0
        public ActionResult AutoComplete(string searchType, string term)
        {
            //InitSearch();
            ////Call autocomplete API and return results
            //AutocompleteParameters ap = new AutocompleteParameters()
            //{
            //    AutocompleteMode = AutocompleteMode.OneTermWithContext,
            //    UseFuzzyMatching = false,
            //    Top = 5
            //};
            //AutocompleteResult autocompleteResult = _indexClient.Documents.Autocomplete(term, "sg", ap);
            AutocompleteResult autocompleteResult = _jobsSearch.AutoComplete(GetIndexNameType(searchType), term);
            // Conver the Suggest results to a list that can be displayed in the client.
            List <string> autocomplete = autocompleteResult.Results.Select(x => x.Text).ToList();

            return(new JsonResult(autocomplete));
            //return new JsonResult(new
            //{
            //    JsonRequestBehavior = 0,
            //    Data = autocomplete
            //});
        }
Exemplo n.º 26
0
        public async Task <ActionResult> AutoComplete(string term)
        {
            // Use static variables to set up the configuration and Azure service and index clients, for efficiency.
            _builder       = new ConfigurationBuilder().AddJsonFile("appsettings.json");
            _configuration = _builder.Build();

            _serviceClient = CreateSearchServiceClient(_configuration);
            _indexClient   = _serviceClient.Indexes.GetClient("hotels");

            //Call autocomplete API and return results
            AutocompleteParameters ap = new AutocompleteParameters()
            {
                AutocompleteMode = AutocompleteMode.OneTermWithContext,
                UseFuzzyMatching = false,
                Top = 5
            };
            AutocompleteResult autocompleteResult = await _indexClient.Documents.AutocompleteAsync(term, "sg", ap);

            // Convert the autocompleteResult results to a list that can be displayed in the client.
            List <string> autocomplete = autocompleteResult.Results.Select(x => x.Text).ToList();

            return(new JsonResult((object)autocomplete));
        }
Exemplo n.º 27
0
        protected void TestAutocompleteWithFilter()
        {
            var expectedText = new List <string>()
            {
                "polite"
            };
            var expectedQueryPlusText = new List <string>()
            {
                "polite"
            };

            SearchIndexClient client   = GetClientForQuery();
            var autocompleteParameters = new AutocompleteParameters()
            {
                AutocompleteMode = AutocompleteMode.OneTerm,
                Filter           = "search.in(hotelId, '6,7')",
            };

            AutocompleteResult response = client.Documents.Autocomplete("po", "sg", autocompleteParameters);

            Assert.NotNull(response);
            ValidateResults(response.Results, expectedText, expectedQueryPlusText);
        }
Exemplo n.º 28
0
        protected void TestAutocompleteWithFilterAndFuzzy()
        {
            var expectedText = new List <string>()
            {
                "modern", "motel"
            };
            var expectedQueryPlusText = new List <string>()
            {
                "modern", "motel"
            };

            SearchIndexClient client   = GetClientForQuery();
            var autocompleteParameters = new AutocompleteParameters()
            {
                AutocompleteMode = AutocompleteMode.OneTerm,
                UseFuzzyMatching = true,
                Filter           = "hotelId ne '6' and (hotelName eq 'Modern Stay' or tags/any(t : t eq 'budget'))"
            };

            AutocompleteResult response = client.Documents.Autocomplete("mod", "sg", autocompleteParameters);

            Assert.NotNull(response);
            ValidateResults(response.Results, expectedText, expectedQueryPlusText);
        }
Exemplo n.º 29
0
        protected void TestAutocompleteCanUseHitHighlighting()
        {
            var expectedText = new List <string>()
            {
                "pool", "popular"
            };
            var expectedQueryPlusText = new List <string>()
            {
                "<b>pool</b>", "<b>popular</b>"
            };

            SearchIndexClient client   = GetClientForQuery();
            var autocompleteParameters = new AutocompleteParameters()
            {
                AutocompleteMode = AutocompleteMode.OneTerm,
                Filter           = "hotelName eq 'EconoStay' or hotelName eq 'Fancy Stay'",
                HighlightPreTag  = "<b>",
                HighlightPostTag = "</b>",
            };
            AutocompleteResult response = client.Documents.Autocomplete("po", "sg", autocompleteParameters);

            Assert.NotNull(response);
            ValidateResults(response.Results, expectedText, expectedQueryPlusText);
        }
Exemplo n.º 30
0
        /// <summary>
        /// Implementation Notes - The full text service allows you to search for features / places / street
        /// and do autocompletion.you can : Specify one or more words search on part of the name(auto completion / suggestion)
        /// Search for text or zip code Specify a GPS restriction(promote nearest, not sorted but has an impact on the score),
        /// Limit the results to a specific Language, Country, place type, Paginate the results, Specify the output verbosity,
        /// Tells if you want the output to be indented, Tells that all words are required or not, The search is case
        /// insensitive, use synonyms(Saint/st, ..), separator characters stripping, ...
        /// </summary>
        /// <param name="text">The searched text : The text for the query can be a zip code, a string or one or more strings</param>
        /// <param name="allwordsrequired">Whether the fulltext engine should considers all the words specified as required. Defaults to false (since v 4.0). possible values are true|false (or 'on' when used with the rest service)</param>
        /// <param name="spellchecking">The spellchecking (optional) : whether some suggestions should be provided if no results are found</param>
        /// <param name="lat">The latitude (north-south) for the location point to search around. The value is a floating number, between -90 and +90. It uses GPS coordinates</param>
        /// <param name="lng">The longitude (east-West) for the location point to search around. The value is a floating number between -180 and +180. It uses GPS coordinates.</param>
        /// <param name="radius">Distance from the location point in meters we'd like to search around. The value is a number > 0 if it is not specify or incorrect.</param>
        /// <param name="suggest">If this parameter is set then it will search in part of the names of the street, place,.... It allow you to do auto completion auto suggestion. See the Gisgraphy leaflet plugin for more details. The JSON format will be forced if this parameter is true. See auto completion / suggestions engine for more details</param>
        /// <param name="style" cref="Styles">The output style verbosity (optional) : Determines the output verbosity. 4 styles are available</param>
        /// <param name="country">Limit the search to the specified ISO 3166 country code. Default : search in all countries</param>
        /// <param name="lang">The language code (optional) : The iso 639 Alpha2 or alpha3 Language Code. Some properties such as the AlternateName AdmNames and countryname belong to a certain language code. The language parameter can limit the output of those fields to a certain language (it only apply when style parameter='style') : If the language code does not exists or is not specified, properties with all the languages are retrieved If it exists, the properties with the specified language code, are retrieved</param>
        /// <returns><see cref="AutocompleteResult"/> </returns>
        public async Task <AutocompleteResult> autocompleteAsync(string text, bool allwordsrequired = false, string spellchecking = null, double?lat = null, double?lng = null, double radius = 10000, bool suggest = false, Styles style = Styles.MEDIUM, string country = null, string lang = null)
        {
            if (string.IsNullOrEmpty(text))
            {
                throw new ArgumentNullException("Search text cannot be blank");
            }
            if (lat.HasValue && (lat.Value > 90 || lat.Value < -90))
            {
                throw new ArgumentOutOfRangeException("Latitude must be between -90 an 90");
            }
            if (lng.HasValue && (lng.Value > 180 || lng.Value < -180))
            {
                throw new ArgumentOutOfRangeException("Longitude must be between -180 and 180");
            }
            if ((lat.HasValue && !lng.HasValue) || (!lat.HasValue && lng.HasValue))
            {
                throw new ArgumentNullException("If using latitude and longitude, both values must be provided");
            }
            if (radius <= 0)
            {
                throw new ArgumentOutOfRangeException("Radius must be greater than 0");
            }
            if (!string.IsNullOrEmpty(country) && country.Length != 2)
            {
                throw new ArgumentOutOfRangeException("Country needs to be the ISO 3166 Alpha 2 code");
            }
            if (!string.IsNullOrEmpty(lang) && lang.Length != 2 && lang.Length != 3)
            {
                throw new ArgumentOutOfRangeException("Language needs to be the ISO 639 Alpha 2 or Alpha 3 code");
            }

            AutocompleteResult result = new AutocompleteResult();

            using (var client = DefaultClient)
            {
                Dictionary <string, string> param = DefaultParams;
                param.Add("q", text);
                param.Add("allwordsrequired", allwordsrequired.ToString().ToLower());
                if (!string.IsNullOrEmpty(spellchecking))
                {
                    param.Add("spellchecking", spellchecking);
                }
                if (lat.HasValue && lng.HasValue)
                {
                    param.Add("lat", lat.ToString());
                    param.Add("lng", lng.ToString());
                }
                param.Add("radius", radius.ToString());
                param.Add("suggest", suggest.ToString().ToLower());
                switch (style)
                {
                case Styles.FULL:
                    param.Add("style", "FULL");
                    break;

                case Styles.LONG:
                    param.Add("style", "LONG");
                    break;

                case Styles.MEDIUM:
                    param.Add("style", "MEDIUM");
                    break;

                case Styles.SHORT:
                    param.Add("style", "SHORT");
                    break;
                }
                if (!string.IsNullOrEmpty(country))
                {
                    param.Add("country", country);
                }
                if (!string.IsNullOrEmpty(lang))
                {
                    param.Add("lang", lang);
                }

                var response = await client.GetAsync(string.Format("{0}{1}", Gisgraphy.FULLTEXT_AUTOCOMPLETE, param.ToQueryString()));

                if (!response.IsSuccessStatusCode)
                {
                    result.response.resultsFound = 0;
                    result.message = await response.Content.ReadAsStringAsync();
                }
                else
                {
                    try
                    {
                        result = JsonConvert.DeserializeObject <AutocompleteResult>(await response.Content.ReadAsStringAsync());
                    }
                    catch (JsonSerializationException ex)
                    {
                        result.response.resultsFound = 0;
                        result.message = string.Format("{0}\n{1}", ex.Message, ex.StackTrace);
                    }
                }
            }
            return(result);
        }