我正在编写下面的代码,我想要做的是按对象本身查询.
例如:我有一个搜索表单,填充下面的对象字段.那么我想要做的是根据填写表单的用户搜索弹性搜索.
ie:下面,我想通过searchItem对象查询索引.我怎么能轻易做到?
class Program
{
static void Main(string[] args)
{
var p = new Program();
var item1 = new Announcement() {Id=1, Title = "john", ContentText = "lorem", Bar = false, Num = 99, Foo = "hellow"};
//p.Index(item1, "add");
var searchItem = new Announcement() {Title="john",Num=99};
ElasticClient.Search<Announcement>();
Console.Read();
}
public void Index(Announcement announcement, String operation)
{
var uriString = "http://localhost:9200";
var searchBoxUri = new Uri(uriString);
var settings = new ConnectionSettings(searchBoxUri);
settings.SetDefaultIndex("test");
var client = new ElasticClient(settings);
if (operation.Equals("delete"))
{
client.DeleteById("test", "announcement", …Run Code Online (Sandbox Code Playgroud)