First time using ElasticSearch (using NEST as the wrapper). I want to search in an external ElasticSearch database.
I simply want to run a test query towards a specific field called cvrNummer
. I have the following code, which doesn't compile because: The type arguments for method 'ElasticSearch.Search<T> .. ', cannot be inferred from the usage.
I assume it's because I cannot specify the type-specific class. Challenge is I don't know that one.
My question is: how do I run the query below, without exactly know what I get back (to make a type-specific model)? And if I need that model, how do I "make" that model when the documentation is lacking?
My code:
var settings = new ConnectionSettings(new Uri(_path)).
BasicAuthentication(_username,_password);
var client = new ElasticClient(settings);
var es_query = new TermsQuery
{
Name = "named_query",
Boost = 1.1,
Field = "cvrNummer",
Terms = new string[] { "36406208" }
};
client.Search(es_query);
Only documentation I have:
curl -u "<brugernavn>:<password>" -XPOST http://URL -d'
{ "from" : 0, "size" : 1,
"query": {
"term": {
"cvrNummer": VALUE
}
}
}
EDIT MORE DATA:
Document model from documentation:
curl -u "<brugernavn>:<password>" -XGET http://distribution.virk.dk/cvr-permanent/_mapping
Full search example:
curl -u "<brugernavn>:<password>" -XPOST http://distribution.virk.dk/cvr-permanent/_search -d'
{ "from" : 0, "size" : 1,
"query": {
"term": {
"cvrNummer": 10961211
}
}
}
'