Ejemplo n.º 1
0
        public DocumentResult GetDocumentById(string id)
        {
            var decodedPath = id;

            var response = LookUp(id);

            if (_isPathBase64Encoded)
            {
                decodedPath = Base64Decode(id);
            }

            int storageIndex;
            string tokenToUse = GetToken(decodedPath, out storageIndex);

            var result = new DocumentResult
            {
                Result = response,
                Token = tokenToUse,
                StorageIndex = storageIndex,
                DecodedPath = decodedPath,
                IdField = idField,
                IsPathBase64Encoded = _isPathBase64Encoded
            };
            return result;
        }
Ejemplo n.º 2
0
        public DocumentResult GetDocuments(string q, SearchFacet[] searchFacets, int currentPage, string polygonString = null)
        {
            GetContainerSasUris();

            var selectFilter = Model.SelectFilter;

            if (!string.IsNullOrEmpty(q))
            {
                q = q.Replace("?", "");
            }

            var response = Search(q, searchFacets, selectFilter, currentPage, polygonString);
            var searchId = GetSearchId().ToString();
            var facetResults = new List<Facet>();
            var tagsResults = new List<object>();

            if (response != null && response.Facets != null)
            {
                // Return only the selected facets from the Search Model
                foreach (var facetResult in response.Facets.Where(f => Model.Facets.Where(x => x.Name == f.Key).Any()))
                {
                    var cleanValues = GetCleanFacetValues(facetResult);

                    facetResults.Add(new Facet
                    {
                        key = facetResult.Key,
                        value = cleanValues
                    });
                }

                foreach (var tagResult in response.Facets.Where(t => Model.Tags.Where(x => x.Name == t.Key).Any()))
                {
                    var cleanValues = GetCleanFacetValues(tagResult);

                    tagsResults.Add(new
                    {
                        key = tagResult.Key,
                        value = cleanValues
                    });
                }
            }

            var result = new DocumentResult
            {
                Results = (response == null ? null : response.GetResults()),
                Facets = facetResults,
                Tags = tagsResults,
                Count = (response == null ? 0 : Convert.ToInt32(response.TotalCount)),
                SearchId = searchId,
                IdField = idField,
                Token = s_tokens[0],
                IsPathBase64Encoded = _isPathBase64Encoded
            };

            string json = JsonConvert.SerializeObject(facetResults);


            return result;
        }