codec.asciidoc 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. [[index-modules-codec]]
  2. == Codec module
  3. Codecs define how documents are written to disk and read from disk. The
  4. postings format is the part of the codec that responsible for reading
  5. and writing the term dictionary, postings lists and positions, payloads
  6. and offsets stored in the postings list.
  7. Configuring custom postings formats is an expert feature and most likely
  8. using the builtin postings formats will suite your needs as is described
  9. in the <<mapping-core-types,mapping section>>
  10. [float]
  11. === Configuring a custom postings format
  12. Custom postings format can be defined in the index settings in the
  13. `codec` part. The `codec` part can be configured when creating an index
  14. or updating index settings. An example on how to define your custom
  15. postings format:
  16. [source,js]
  17. --------------------------------------------------
  18. curl -XPUT 'http://localhost:9200/twitter/' -d '{
  19. "settings" : {
  20. "index" : {
  21. "codec" : {
  22. "postings_format" : {
  23. "my_format" : {
  24. "type" : "pulsing",
  25. "freq_cut_off" : "5"
  26. }
  27. }
  28. }
  29. }
  30. }
  31. }'
  32. --------------------------------------------------
  33. Then we defining your mapping your can use the `my_format` name in the
  34. `postings_format` option as the example below illustrates:
  35. [source,js]
  36. --------------------------------------------------
  37. {
  38. "person" : {
  39. "properties" : {
  40. "second_person_id" : {"type" : "string", "postings_format" : "my_format"}
  41. }
  42. }
  43. }
  44. --------------------------------------------------
  45. [float]
  46. === Available postings formats
  47. [float]
  48. ==== Direct postings format
  49. Wraps the default postings format for on-disk storage, but then at read
  50. time loads and stores all terms & postings directly in RAM. This
  51. postings format makes no effort to compress the terms and posting list
  52. and therefore is memory intensive, but because of this it gives a
  53. substantial increase in search performance. Because this holds all term
  54. bytes as a single byte[], you cannot have more than 2.1GB worth of terms
  55. in a single segment.
  56. This postings format offers the following parameters:
  57. `min_skip_count`::
  58. The minimum number terms with a shared prefix to
  59. allow a skip pointer to be written. The default is *8*.
  60. `low_freq_cutoff`::
  61. Terms with a lower document frequency use a
  62. single array object representation for postings and positions. The
  63. default is *32*.
  64. Type name: `direct`
  65. [float]
  66. ==== Memory postings format
  67. A postings format that stores terms & postings (docs, positions,
  68. payloads) in RAM, using an FST. This postings format does write to disk,
  69. but loads everything into memory. The memory postings format has the
  70. following options:
  71. `pack_fst`::
  72. A boolean option that defines if the in memory structure
  73. should be packed once its build. Packed will reduce the size for the
  74. data-structure in memory but requires more memory during building.
  75. Default is *false*.
  76. `acceptable_overhead_ratio`::
  77. The compression ratio specified as a
  78. float, that is used to compress internal structures. Example ratios `0`
  79. (Compact, no memory overhead at all, but the returned implementation may
  80. be slow), `0.5` (Fast, at most 50% memory overhead, always select a
  81. reasonably fast implementation), `7` (Fastest, at most 700% memory
  82. overhead, no compression). Default is `0.2`.
  83. Type name: `memory`
  84. [float]
  85. ==== Bloom filter posting format
  86. The bloom filter postings format wraps a delegate postings format and on
  87. top of this creates a bloom filter that is written to disk. During
  88. opening this bloom filter is loaded into memory and used to offer
  89. "fast-fail" reads. This postings format is useful for low doc-frequency
  90. fields such as primary keys. The bloom filter postings format has the
  91. following options:
  92. `delegate`::
  93. The name of the configured postings format that the
  94. bloom filter postings format will wrap.
  95. `fpp`::
  96. The desired false positive probability specified as a
  97. floating point number between 0 and 1.0. The `fpp` can be configured for
  98. multiple expected insertions. Example expression: *10k=0.01,1m=0.03*. If
  99. number docs per index segment is larger than *1m* then use *0.03* as fpp
  100. and if number of docs per segment is larger than *10k* use *0.01* as
  101. fpp. The last fallback value is always *0.03*. This example expression
  102. is also the default.
  103. Type name: `bloom`
  104. [float]
  105. ==== Pulsing postings format
  106. The pulsing implementation in-lines the posting lists for very low
  107. frequent terms in the term dictionary. This is useful to improve lookup
  108. performance for low-frequent terms. This postings format offers the
  109. following parameters:
  110. `min_block_size`::
  111. The minimum block size the default Lucene term
  112. dictionary uses to encode on-disk blocks. Defaults to *25*.
  113. `max_block_size`::
  114. The maximum block size the default Lucene term
  115. dictionary uses to encode on-disk blocks. Defaults to *48*.
  116. `freq_cut_off`::
  117. The document frequency cut off where pulsing
  118. in-lines posting lists into the term dictionary. Terms with a document
  119. frequency less or equal to the cutoff will be in-lined. The default is
  120. *1*.
  121. Type name: `pulsing`
  122. [float]
  123. ==== Default postings format
  124. The default postings format has the following options:
  125. `min_block_size`::
  126. The minimum block size the default Lucene term
  127. dictionary uses to encode on-disk blocks. Defaults to *25*.
  128. `max_block_size`::
  129. The maximum block size the default Lucene term
  130. dictionary uses to encode on-disk blocks. Defaults to *48*.
  131. Type name: `default`