Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

per_field_analyzer in term vectors api should work even if field does not store term vectors #17076

Closed
brwe opened this issue Mar 11, 2016 · 1 comment
Assignees
Labels
>bug :Search/Search Search-related issues that do not fall into other categories

Comments

@brwe
Copy link
Contributor

brwe commented Mar 11, 2016

Tested with elasticsearch version 2.2

The purpose of per_field_analyzer is to get a term vector as created by an analyzer different from the one the field is indexed with. I would expect to get a term vector for a field even if it does not have term vectors stored. Instead I get an NPE:


POST test/doc/1
{
  "text": "I am a happy hippo"
}


GET  test/doc/1/_termvectors
{
  "per_field_analyzer": {
    "text": "keyword"
  }
}

If I set "term_vector": "yes", in the mapping first all works as expected:

PUT test 
{
  "mappings": {
    "doc": {
      "properties": {
        "text": {
          "term_vector": "yes",
          "type": "string"
        }
      }
    }
  }
}

POST test/doc/1
{
  "text": "I am a happy hippo"
}

GET  test/doc/1/_termvectors
{
  "per_field_analyzer": {
    "text": "keyword"
  }
}

results in (as expected):

{
  "_index": "test",
  "_type": "doc",
  "_id": "1",
  "_version": 1,
  "found": true,
  "took": 1,
  "term_vectors": {
    "text": {
      "field_statistics": {
        "sum_doc_freq": 5,
        "doc_count": 1,
        "sum_ttf": 5
      },
      "terms": {
        "I am a happy hippo": {
          "term_freq": 1,
          "tokens": [
            {
              "position": 0,
              "start_offset": 0,
              "end_offset": 18
            }
          ]
        }
      }
    }
  }
}
@brwe brwe self-assigned this Mar 11, 2016
@clintongormley clintongormley added :Search/Search Search-related issues that do not fall into other categories and removed :Term Vectors labels Feb 14, 2018
@andyb-elastic
Copy link
Contributor

It looks like this works on master, no longer throwing an NPE as described

@elastic/es-search-aggs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>bug :Search/Search Search-related issues that do not fall into other categories
Projects
None yet
Development

No branches or pull requests

3 participants