sramalin
(siva ramalingam)
August 10, 2017, 3:46pm
1
In elasticsearch help at
Multi term vectors API | Elasticsearch Guide [8.11] | Elastic
there is an _mtermvectors endpoint like this
POST /twitter/tweet/_mtermvectors
{
"ids" : ["1", "2"],
"parameters": {
"fields": [
"message"
],
"term_statistics": true
}
}
What is the corresponding call in NEST
I tried
var res = Client.MultiTermVectors(new MultiTermVectorsRequest("twitter", "tweet")
{
TermStatistics = true
});
How can i specify the ids array? Thanks for the help!
sramalin
(siva ramalingam)
August 12, 2017, 11:11pm
2
Used the lowlevel call like below if anyone needs it
string sbRequestBody = "{\"ids\":[\"1\", \"2\"],\"parameters\":{\"fields\": [\"message\"],\"term_statistics\":true}}";
var termvecResponse =Client.LowLevel.Mtermvectors<MultiTermVectorsResponse>("twitter", "tweet", sbRequestBody);
foreach (var doc in termvecResponse.Body.Documents)
{
var item = doc.TermVectors["message"];
Console.WriteLine("Document: {0}",doc.Id);
foreach (var term in item.Terms)
{
Console.WriteLine("{0}: {1}", term.Key, term.Value.TermFrequency);
}
}
High level call:
var tvecR = client.MultiTermVectors(new MultiTermVectorsRequest("twitter", typeof(tweet))
{
Fields = Infer.Fields<tweet>(f => f.Body), // all docs will use these fields
Documents = idRange.Select(n => new MultiTermVectorOperation<tweet>(n)
{
TermStatistics = true
})
});
system
(system)
Closed
September 9, 2017, 11:11pm
3
This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.