Accessing terms in TermVectorResponse

Hello,

I'm trying to get a list of Terms from a termvectorresponse in an elasticsearch plugin. I want to get access to all of the statistics which are tied to the terms and am having trouble figuring out how to do that.

After making a TermVectorsRequest...

TermVectorsRequest tvReq = new TermVectorsRequest(request.param("index"), request.param("type"), request.param("id"));
tvReq.termStatistics(true);
tvReq.selectedFields(request.param("field"));

and getting a response from the client...

TermVectorsResponse tvResponse = client.termVectors(tvReq).get();

I can get access to the id, index, etc. In the fields I get "contents" which is the field name that I want. From there though it looks like I can run...

tvResponse.getFields().terms("some term here")

in which the Terms object this returns has access to the stats I want.

I have a few issues with this though. One is that only "contents" seems to be non null. If I run the _termvectors endpoint with term stats turned on in kibana I get a slew of terms

{
  "_index": "computervectors",
  "_type": "doc",
  "_id": "1",
  "_version": 1,
  "found": true,
  "took": 4,
  "term_vectors": {
"contents": {
  "terms": {
    "5": {
      "doc_freq": 75,
      "ttf": 118,
      "term_freq": 1
    },
    "13": {
      "doc_freq": 20,
      "ttf": 28,
      "term_freq": 1
    },
    "14": {
      "doc_freq": 20,
      "ttf": 25,
      "term_freq": 1
    },
    "20": {
      "doc_freq": 50,
      "ttf": 66,
      "term_freq": 1
    },
    "25": {
      "doc_freq": 34,
      "ttf": 49,
      "term_freq": 1
    },
    "1988": {
      "doc_freq": 31,
      "ttf": 35,
      "term_freq": 1
    },...

Any of these terms I try don't seem to work.

Two, is I want to get a list of terms rather than having to type in which term I want.

How can I go about doing this?

Thanks

I've figured it out. Had to access the iterator, and then everything else I was able to figure out via lucene documentation. This can be closed.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.