Hi,
I am very new to ElasticSearch and started reading about it only a day back.
The main reason as to why we chose this was to Schedule an event whenever the data chosen by the query changes.
To do this, I was trying to create a sample Watch, but with no results.
I was able to create an index and search the index. But when I try to create a Watch, I am getting the error:
Invalid NEST response built from a unsuccessful low level call on PUT.
Please find below the code:
public static void test()
{
try
{
var settings = new ConnectionSettings(new Uri("http://localhost:9200"))
.DefaultIndex("mypersonindex")
.DisableDirectStreaming(true);
var client = new ElasticClient(settings);
if (!client.IndexExists("mypersonindex").Exists)
{
client.CreateIndex("mypersonindex");
}
var personList = new List<Person>();
var person1 = new Person
{
Id = 1,
FirstName = "First1",
LastName = "Last1",
Time = DateTime.Now
};
var person2 = new Person
{
Id = 2,
FirstName = "First2",
LastName = "Last2",
Time = DateTime.Now
};
var person3 = new Person
{
Id = 3,
FirstName = "First3",
LastName = "Last3",
Time = DateTime.Now
};
personList.Add(person1);
personList.Add(person2);
personList.Add(person3);
var indexResponse = client.Index(person1, idx => idx.Index("mypersonindex"));
var indexResponse1 = client.Index(person2, idx => idx.Index("mypersonindex"));
var indexResponse2 = client.Index(person3, idx => idx.Index("mypersonindex"));
var searchResponse = client.Search<Person>(s => s.Index("mypersonindex")
.From(0)
.Size(10)
.Query(q => q
.Match(m => m
.Field(f => f.FirstName)
.Query("First1")
)
)
);
var people = searchResponse.Documents;
// I get a successful response here - with one record
**var responseWatch = client.PutWatch("my_watch");**
// this line throws the error with PUT and the below throws the error with GET
var response = client.GetWatch("my_watch");
}
catch(Exception ex)
{
Console.WriteLine(ex.Message);
}
}
Any inputs would be really helpful!
Looking forward to the response.
Thanks!