I am trying to write a simple console app using C# and NEST to learn more about Elasticsearch.
I can run the following query in Sense (Kibana)
GET /companies/company/_search
{
"query": {
"match": {
"dbaName": "STEAK"
}
}
}
and I will get back the following result:
{
"took": 1,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"failed": 0
},
"hits": {
"total": 1,
"max_score": 0.15342641,
"hits": [
{
"_index": "companies",
"_type": "company",
"_id": "1",
"_score": 0.15342641,
"_source": {
"dbaName": "We do steak",
"primaryLicenseStatus": "T",
"primaryLicenseDescription": "Restuarant",
"lastActivityDate": "2016-06-06T08:25:23.4136549-04:00"
}
}
]
}
}
However, when I try to do this query using NEST, I get no results:
var response = client.Search<Company>(s => s
.Index(theIndex)
.Query(q =>
q.Match(m => m.Field(f => f.DbaName).Query("steak"))
)
);
UPDATE - I figured it out!
So I feel like I should take this post down since the question has no relevance to the solution.
Spoiler: My query in NEST is fine.
I had created a console app that would start by deleting the index, re-creating it, insert the Company and then search for it.
The server was not keeping up with my console app and only when I stopped deleting/recreating the index was I able to get the search to work. (facepalm)
If any feel that I should simply delete this thread, let me know in the comments below and I will remove it, but someone may find it helpful.