Skip to content

Instantly share code, notes, and snippets.

@soumyamrs
Created August 23, 2012 08:41
Show Gist options
  • Save soumyamrs/3434337 to your computer and use it in GitHub Desktop.
Save soumyamrs/3434337 to your computer and use it in GitHub Desktop.
NEST application
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.Script.Serialization;
using Nest;
using ExcelDna.Integration;
using System.Data;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
namespace ClassLibrary1
{
public class ESIntegration : IExcelAddIn
{
public static ElasticClient client=null;
public class NewTypes
{
private string p;
public NewTypes(string p)
{
// TODO: Complete member initialization
this.p = p;
}
public int ID { get; set; }
public string Name { get; set; }
}
public static object getTitle(String docID)
{
client = ESClient.getConnection();
if (client != null)
{
var result = client.Search(s => s
.Index("algotest")
.MatchAll()
);
alert(result.Hits.Total.ToString());
foreach (var res in result.DocumentsWithMetaData.ToList())
{
string Title = res.Fields["title"];
alert(Title);
}
return "Sucess";
}
return "client is null";
}
public static void alert(String s)
{
ExcelAsyncUtil.QueueAsMacro(delegate
{
XlCall.Excel(XlCall.xlcAlert, s);
});
}
private static DataTable CreateTable(string inputStr)
{
DataTable tmpTable = new DataTable();
if (inputStr == null)
return tmpTable;
DataColumn column;
DataRow row;
try
{
column = new DataColumn();
column.ColumnName = "Product";
column.ReadOnly = true;
column.Unique = false;
tmpTable.Columns.Add(column);
alert(" return DataTable");
return tmpTable;
}
catch
{
// return null;
throw;
}
}
public void AutoClose()
{
ExcelAsyncUtil.Initialize();
ExcelIntegration.RegisterUnhandledExceptionHandler(
ex => "!!! EXCEPTION: " + ex.ToString());
}
public void AutoOpen()
{
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment