public static IActionResult GetFacetGraphNodes([HttpTrigger(AuthorizationLevel.Function, "post", Route = null)] HttpRequest req, TraceWriter log, ExecutionContext executionContext) { string skillName = executionContext.FunctionName; if (!req.QueryString.HasValue) { return(new BadRequestObjectResult($"{skillName} - Requires a query string in the following format: q=oswald&f=entities")); } string searchServiceName = GetAppSetting("SearchServiceName"); string searchServiceApiKey = GetAppSetting("SearchServiceApiKey"); string indexName = String.IsNullOrEmpty(req.Headers["IndexName"]) ? Config.AZURE_SEARCH_INDEX_NAME : (string)req.Headers["IndexName"]; if (String.IsNullOrEmpty(searchServiceName) || String.IsNullOrEmpty(searchServiceApiKey) || String.IsNullOrEmpty(indexName)) { return(new BadRequestObjectResult($"{skillName} - Information for the search service is missing")); } SearchClientHelper searchClient = new SearchClientHelper(searchServiceName, searchServiceApiKey, indexName); FacetGraphGenerator facetGraphGenerator = new FacetGraphGenerator(searchClient); string query = string.IsNullOrEmpty(req.Query["q"].FirstOrDefault()) ? "*" : req.Query["q"].First(); string facet = string.IsNullOrEmpty(req.Query["f"].FirstOrDefault()) ? "entities" : req.Query["f"].First(); JObject facetGraph = facetGraphGenerator.GetFacetGraphNodes(query, facet); return((ActionResult) new OkObjectResult(facetGraph)); }
public JObject GetGraphData(string query) { if (query == null) { query = "*"; } FacetGraphGenerator graphGenerator = new FacetGraphGenerator(_docSearch); var graphJson = graphGenerator.GetFacetGraphNodes(query, "keyPhrases"); return(graphJson); }
public JObject GetGraphData(string query) { string facetName = _configuration.GetSection("GraphFacet")?.Value; if (query == null) { query = "*"; } FacetGraphGenerator graphGenerator = new FacetGraphGenerator(_docSearch); var graphJson = graphGenerator.GetFacetGraphNodes(query, facetName); return(graphJson); }
public JObject GetGraphData(string query) { string facetsList = _configuration.GetSection("GraphFacet")?.Value; string[] facetNames = facetsList.Split(new char[] { ',', ' ' }, StringSplitOptions.RemoveEmptyEntries); if (query == null) { query = "*"; } FacetGraphGenerator graphGenerator = new FacetGraphGenerator(_docSearch); var graphJson = graphGenerator.GetFacetGraphNodes(query, facetNames.ToList <string>()); return(graphJson); }
public async Task <IActionResult> Get(string facet, string query) { if (string.IsNullOrWhiteSpace(query)) { query = "*"; } if (string.IsNullOrWhiteSpace(facet)) { facet = "keyPhrases"; } var graphJson = await FacetGraphGenerator.GetGraphNodes(_searchConfig, query, facet); return(new JsonResult(graphJson)); }
public ActionResult GetGraphData(string query, string[] fields, int maxLevels, int maxNodes) { string[] facetNames = fields; if (facetNames == null || facetNames.Length == 0) { string facetsList = _configuration.GetSection("GraphFacet")?.Value; facetNames = facetsList.Split(new char[] { ',', ' ' }, StringSplitOptions.RemoveEmptyEntries); } if (query == null) { query = "*"; } FacetGraphGenerator graphGenerator = new FacetGraphGenerator(_docSearch); var graphJson = graphGenerator.GetFacetGraphNodes(query, facetNames.ToList <string>(), maxLevels, maxNodes); return(Content(graphJson.ToString(), "application/json")); }