public virtual ActionResult Search() { try { var req = Request.InputStream; req.Seek(0, System.IO.SeekOrigin.Begin); string json; using (var reader = new StreamReader(Request.InputStream)) json = reader.ReadToEnd(); SearchParameters searchParams = JsonConvert.DeserializeObject <SearchParameters>(json); string lang = GetLanguage(searchParams); ICriteria criteria; if (cjk.Contains(lang)) { string queryString = GetSearchQueryString(searchParams); string pubId = GetPublicationId(searchParams); if (pubId != null) { var q = new SearchQuery().GroupStart() .Field(PUBLICATION_ONLINE_STATUS_FIELD, PUBLICATION_ONLINE_STATUS_VALUE) .And().Field("publicationId", new DefaultTermValue(pubId)) .GroupEnd() .And() .GroupStart() .Field("content.cjk", queryString) .Or() .Field($"content.{lang}", queryString) .GroupEnd(); criteria = q.Compile(); } else { var q = new SearchQuery().GroupStart() .Field(PUBLICATION_ONLINE_STATUS_FIELD, PUBLICATION_ONLINE_STATUS_VALUE) .GroupEnd() .And() .GroupStart() .Field("content.cjk", queryString) .Or() .Field($"content.{lang}", queryString) .GroupEnd(); criteria = q.Compile(); } } else { criteria = SingleLanguageSearchQuery(searchParams); } var search = ApiClientFactory.Instance.CreateSearchClient <SearchResultSet, SearchResult>(); var results = search.WithResultFilter(new SearchResultFilter { StartOfRange = searchParams.StartIndex, EndOfRange = searchParams.StartIndex + searchParams.Count, IsHighlightingEnabled = true }).Search(criteria); var resultSet = new SearchResultSetWrapped(results) { Hits = results.Hits, Count = searchParams.Count.Value, StartIndex = searchParams.StartIndex.Value }; return(Json(resultSet)); } catch (Exception) { Response.StatusCode = 405; return(new EmptyResult()); } }