Search code examples
elasticsearchvectorterm-vectors

Elasticsearch termvector API not working


I've set the mapping the title field for the article type for the testindex1 index as follows:

PUT /testindex1/article/_mapping
{
  "article": {
    "type": "object",
    "dynamic": false,
    "properties": {
      "title": {
        "type": "string",
        "store": true,
        "term_vector": "with_positions_offsets",
        "_index": {
          "enabled": true
        }
      },
    }
  }
}

omitting the remainder of the mapping specification. (This example and those that follow assume the Marvel Sense dashboard interface.) testindex1 is then populated with articles, including article with id 4540.

As expected,

GET /testindex1/article/4540/?fields=title

produces

{
   "_index": "testindex1",
   "_type": "article",
   "_id": "4540",
   "_version": 1,
   "exists": true,
   "fields": {
      "title": "Elasticsearch is the best solution"
  }
}

(The title text has been changed to protect the innocent.)

However,

GET /testindex1/article/4540/_termvector?fields=title

produces

No handler found for uri [/testindex1/article/4540/_termvector?fields=title&_=1404765178625] and method [GET]

I've experimented with variants of the mapping specification, and variants of the termvector request, so far to no avail. I've also looked for tips in official and non-official documentation, and on forums that cover Elasticsearch topics, including Stack Overflow. elasticsearch.org looks authoritative. I expect I've misused the termvector API in a way that will be instantly obvious to people who are familiar with it. Please point out my mistake(s). Thanks.


Solution

  • The _termvector api endpoint for returning term vector stats was only added in the 1.0 Beta - you will need to upgrade if you want to use term vectors.

    Term Vectors

    Note

    Added in 1.0.0.Beta1.

    Returns information and statistics on terms in the fields of a particular document as stored in the index.

    http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/docs-termvectors.html