Advertisement
Guest User

Untitled

a guest
Jan 24th, 2017
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.20 KB | None | 0 0
  1. Setup
  2.  
  3. ```json
  4. PUT /index1
  5. {
  6. "mappings": {
  7. "foo": {
  8. "properties": {
  9. "suggest": {
  10. "type": "completion"
  11. }
  12. }
  13. }
  14. }
  15. }
  16.  
  17. PUT /index1/foo/1
  18. {
  19. "suggest": {
  20. "input": ["bar"],
  21. "output": "From Index 1"
  22. }
  23. }
  24.  
  25. PUT /index2
  26. {
  27. "mappings": {
  28. "foo": {
  29. "properties": {
  30. "suggest": {
  31. "type": "completion"
  32. }
  33. }
  34. }
  35. }
  36. }
  37.  
  38. PUT /index2/foo/1
  39. {
  40. "suggest": {
  41. "input": ["bar"],
  42. "output": "From Index 2"
  43. }
  44. }
  45. ```
  46.  
  47. Suggest Request
  48. ```json
  49. GET /index1,index2/_search?search_type=count
  50. {
  51. "suggest": {
  52. "mysuggestions": {
  53. "text": "b",
  54. "completion": {
  55. "field": "suggest"
  56. }
  57. }
  58. }
  59. }
  60. ```
  61.  
  62.  
  63. Response
  64. ```json
  65. {
  66. "took": 3,
  67. "timed_out": false,
  68. "_shards": {
  69. "total": 10,
  70. "successful": 10,
  71. "failed": 0
  72. },
  73. "hits": {
  74. "total": 2,
  75. "max_score": 0,
  76. "hits": []
  77. },
  78. "suggest": {
  79. "mysuggestions": [
  80. {
  81. "text": "b",
  82. "offset": 0,
  83. "length": 1,
  84. "options": [
  85. {
  86. "text": "From Index 1",
  87. "score": 1
  88. },
  89. {
  90. "text": "From Index 2",
  91. "score": 1
  92. }
  93. ]
  94. }
  95. ]
  96. }
  97. }
  98. ```
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement