2

I want to store term vectors of a field but I have doubt in my mind. In the documentation they say:

"mappings": {
    "tweet": {
      "properties": {
        "text": {
          "type": "text",
          "term_vector": "with_positions_offsets_payloads",
          "store" : true,
          "analyzer" : "fulltext_analyzer"
         }
      }
    }
  }

Will store the term vectors. But the term vectors are accessible only through a certain endpoint:

/twitter/tweet/1/_termvectors

And what will be stored is the field text. So what if I want to store my term vectors but not the field text. Will it store the term vectors if I don't specify "store":true? How can I be sure my term vectors are stored and not computed on the fly?

mel
  • 2,730
  • 8
  • 35
  • 70

2 Answers2

1

The term vectors will be stored when you have term_vector specified in the mapping (with any of the possible options except no of course). See the term_vector docs -- the example mapping there does not include "store":true, and the docs specifically say the term vector will be stored.

dshockley
  • 1,494
  • 10
  • 13
  • Thanks I used: https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-termvectors.html but they don't specify it! And is there a way to make sure that the term vectors are not generated on the fly? Because there is currently no difference between calling the stored term vectors or generating them on the fly – mel Aug 30 '17 at 07:20
  • 2
    I can't find a good way to prove it (I've tried turning on trace logging and I don't see anything useful), but there is evidence: (1) if I call `_termvectors` without `fields` specified, the response includes only the field mapped with `term_vector`, and (2) if I specify the field without the term_vector mapping, the execution time of the query takes longer (by the value in `took` in the response). – dshockley Aug 30 '17 at 07:50
  • 1
    Also, in the docs you linked, there is an example without `"stored": true`, though they don't explain it clearly (the `fullname` field), and that's mentioned earlier than the "on the fly" parts of the docs. – dshockley Aug 30 '17 at 07:52
  • Thanks for all those explanation! – mel Aug 30 '17 at 08:08
1

Your question is about the difference of the lucene features

Possible https://de.slideshare.net/lucenerevolution/what-is-inaluceneagrandfinal can help:

The stored value of a field is not used at query time. You can use it in your search results and for (slow) highlighting

Only the inverted index is used for searching (possible e.g. with position for phrase queries).

Optional a doc value can be used for ranking

Karsten R.
  • 1,628
  • 12
  • 14