Guest User

Untitled

a guest
Mar 1st, 2015
199
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.49 KB | None | 0 0
  1. [question_index] => Array
  2. (
  3. [mappings] => Array
  4. (
  5. [QUESTION] => Array
  6. (
  7. [properties] => Array
  8. (
  9. [body] => Array
  10. (
  11. [type] => string
  12. )
  13.  
  14. [general_suggest] => Array
  15. (
  16. [type] => completion
  17. [analyzer] => simple
  18. [payloads] => 1
  19. [preserve_separators] => 1
  20. [preserve_position_increments] => 1
  21. [max_input_length] => 50
  22. )
  23. )
  24.  
  25. )
  26.  
  27. )
  28.  
  29. )
  30.  
  31. $param['index'] = 'question_index';
  32. $param['type'] = 'QUESTION';
  33. $param['body'] = array(
  34. '_source' => array(
  35. 'enabled' => true
  36. ),
  37. 'properties' => array(
  38. 'body' => array('type' => 'string'),
  39. 'general_suggest' => array(
  40. 'type' => 'completion',
  41. 'index_analyzer' => 'simple',
  42. 'search_analyzer' => 'simple',
  43. 'payloads' => true
  44. )
  45. )
  46. );
  47. $result = $client->indices()->putMapping($param);
  48.  
  49. $param = array();
  50. $param['index'] = 'question_index';
  51. $param['body']['text'] = 'someth';//should return 'something' as a suggest
  52. $param['body']['completion']['field'] = 'general_suggest';
  53. $result = $client->suggest($param);
  54.  
  55. Array
  56. (
  57. [_shards] => Array
  58. (
  59. [total] => 5
  60. [successful] => 0
  61. [failed] => 5
  62. [failures] => Array
  63. (
  64. [0] => Array
  65. (
  66. [index] => question_index
  67. [shard] => 0
  68. [reason] => BroadcastShardOperationFailedException[[question_index][0] ]; nested: ElasticsearchException[failed to execute suggest]; nested: ElasticsearchIllegalArgumentException[[suggest] does not support [field]];
  69. )
Add Comment
Please, Sign In to add comment