index-prefixes.asciidoc 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. [[index-prefixes]]
  2. === `index_prefixes`
  3. The `index_prefixes` parameter enables the indexing of term prefixes to speed
  4. up prefix searches. It accepts the following optional settings:
  5. [horizontal]
  6. `min_chars`::
  7. The minimum prefix length to index. Must be greater than 0, and defaults
  8. to 2. The value is inclusive.
  9. `max_chars`::
  10. The maximum prefix length to index. Must be less than 20, and defaults to 5.
  11. The value is inclusive.
  12. This example creates a text field using the default prefix length settings:
  13. [source,js]
  14. --------------------------------
  15. PUT my_index
  16. {
  17. "mappings": {
  18. "_doc": {
  19. "properties": {
  20. "body_text": {
  21. "type": "text",
  22. "index_prefixes": { } <1>
  23. }
  24. }
  25. }
  26. }
  27. }
  28. --------------------------------
  29. // CONSOLE
  30. <1> An empty settings object will use the default `min_chars` and `max_chars`
  31. settings
  32. This example uses custom prefix length settings:
  33. [source,js]
  34. --------------------------------
  35. PUT my_index
  36. {
  37. "mappings": {
  38. "_doc": {
  39. "properties": {
  40. "full_name": {
  41. "type": "text",
  42. "index_prefixes": {
  43. "min_chars" : 1,
  44. "max_chars" : 10
  45. }
  46. }
  47. }
  48. }
  49. }
  50. }
  51. --------------------------------
  52. // CONSOLE