Created
August 23, 2012 08:41
-
-
Save soumyamrs/3434337 to your computer and use it in GitHub Desktop.
NEST application
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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