| 1 | package Search::Elasticsearch::Client::5_0::Direct; | ||
| 2 | $Search::Elasticsearch::Client::5_0::Direct::VERSION = '6.81'; | ||
| 3 | use Moo; | ||
| 4 | with 'Search::Elasticsearch::Client::5_0::Role::API'; | ||
| 5 | with 'Search::Elasticsearch::Role::Client::Direct'; | ||
| 6 | |||
| 7 | use Search::Elasticsearch::Util qw(parse_params is_compat); | ||
| 8 | use namespace::clean; | ||
| 9 | |||
| 10 | sub _namespace {__PACKAGE__} | ||
| 11 | |||
| 12 | has 'cluster' => ( is => 'lazy', init_arg => undef ); | ||
| 13 | has 'nodes' => ( is => 'lazy', init_arg => undef ); | ||
| 14 | has 'indices' => ( is => 'lazy', init_arg => undef ); | ||
| 15 | has 'ingest' => ( is => 'lazy', init_arg => undef ); | ||
| 16 | has 'snapshot' => ( is => 'lazy', init_arg => undef ); | ||
| 17 | has 'cat' => ( is => 'lazy', init_arg => undef ); | ||
| 18 | has 'tasks' => ( is => 'lazy', init_arg => undef ); | ||
| 19 | has 'bulk_helper_class' => ( is => 'rw' ); | ||
| 20 | has 'scroll_helper_class' => ( is => 'rw' ); | ||
| 21 | has '_bulk_class' => ( is => 'lazy' ); | ||
| 22 | has '_scroll_class' => ( is => 'lazy' ); | ||
| 23 | |||
| 24 | #=================================== | ||
| 25 | sub _build__bulk_class { | ||
| 26 | #=================================== | ||
| 27 | my $self = shift; | ||
| 28 | my $bulk_class = $self->bulk_helper_class | ||
| 29 | || 'Client::' . $self->api_version . '::Bulk'; | ||
| 30 | $self->_build_helper( 'bulk', $bulk_class ); | ||
| 31 | } | ||
| 32 | |||
| 33 | #=================================== | ||
| 34 | sub _build__scroll_class { | ||
| 35 | #=================================== | ||
| 36 | my $self = shift; | ||
| 37 | my $scroll_class = $self->scroll_helper_class | ||
| 38 | || 'Client::' . $self->api_version . '::Scroll'; | ||
| 39 | $self->_build_helper( 'scroll', $scroll_class ); | ||
| 40 | } | ||
| 41 | |||
| 42 | #=================================== | ||
| 43 | sub bulk_helper { | ||
| 44 | #=================================== | ||
| 45 | my ( $self, $params ) = parse_params(@_); | ||
| 46 | $params->{es} ||= $self; | ||
| 47 | $self->_bulk_class->new($params); | ||
| 48 | } | ||
| 49 | |||
| 50 | #=================================== | ||
| 51 | sub scroll_helper { | ||
| 52 | #=================================== | ||
| 53 | my ( $self, $params ) = parse_params(@_); | ||
| 54 | $params->{es} ||= $self; | ||
| 55 | $self->_scroll_class->new($params); | ||
| 56 | } | ||
| 57 | |||
| 58 | #=================================== | ||
| 59 | sub _build_cluster { shift->_build_namespace('Cluster') } | ||
| 60 | sub _build_nodes { shift->_build_namespace('Nodes') } | ||
| 61 | sub _build_indices { shift->_build_namespace('Indices') } | ||
| 62 | sub _build_ingest { shift->_build_namespace('Ingest') } | ||
| 63 | sub _build_snapshot { shift->_build_namespace('Snapshot') } | ||
| 64 | sub _build_cat { shift->_build_namespace('Cat') } | ||
| 65 | sub _build_tasks { shift->_build_namespace('Tasks') } | ||
| 66 | #=================================== | ||
| 67 | |||
| 68 | __PACKAGE__->_install_api(''); | ||
| 69 | |||
| 70 | 1; | ||
| 71 | |||
| 72 | =pod | ||
| 73 | |||
| 74 | =encoding UTF-8 | ||
| 75 | |||
| 76 | =head1 NAME | ||
| 77 | |||
| 78 | Search::Elasticsearch::Client::5_0::Direct - Thin client with full support for Elasticsearch 5.x APIs | ||
| 79 | |||
| 80 | =head1 VERSION | ||
| 81 | |||
| 82 | version 6.81 | ||
| 83 | |||
| 84 | =head1 SYNOPSIS | ||
| 85 | |||
| 86 | Create a client: | ||
| 87 | |||
| 88 | use Search::Elasticsearch; | ||
| 89 | my $e = Search::Elasticsearch->new( | ||
| 90 | client => '5_0::Direct' | ||
| 91 | ); | ||
| 92 | |||
| 93 | Index a doc: | ||
| 94 | |||
| 95 | $e->index( | ||
| 96 | index => 'my_index', | ||
| 97 | type => 'blog_post', | ||
| 98 | id => 123, | ||
| 99 | body => { | ||
| 100 | title => "Elasticsearch clients", | ||
| 101 | content => "Interesting content...", | ||
| 102 | date => "2013-09-23" | ||
| 103 | } | ||
| 104 | ); | ||
| 105 | |||
| 106 | Get a doc: | ||
| 107 | |||
| 108 | $e->get( | ||
| 109 | index => 'my_index', | ||
| 110 | type => 'my_type', | ||
| 111 | id => 123 | ||
| 112 | ); | ||
| 113 | |||
| 114 | Search for docs: | ||
| 115 | |||
| 116 | $results = $e->search( | ||
| 117 | index => 'my_index', | ||
| 118 | body => { | ||
| 119 | query => { | ||
| 120 | match => { | ||
| 121 | title => "elasticsearch" | ||
| 122 | } | ||
| 123 | } | ||
| 124 | } | ||
| 125 | ); | ||
| 126 | |||
| 127 | Index-level requests: | ||
| 128 | |||
| 129 | $e->indices->create( index => 'my_index' ); | ||
| 130 | $e->indices->delete( index => 'my_index' ) | ||
| 131 | |||
| 132 | Ingest pipeline requests: | ||
| 133 | |||
| 134 | $e->ingest->get_pipeline( id => 'apache-logs' ); | ||
| 135 | |||
| 136 | Cluster-level requests: | ||
| 137 | |||
| 138 | $health = $e->cluster->health; | ||
| 139 | |||
| 140 | Node-level requests: | ||
| 141 | |||
| 142 | $info = $e->nodes->info; | ||
| 143 | $stats = $e->nodes->stats; | ||
| 144 | |||
| 145 | Snapshot and restore: | ||
| 146 | |||
| 147 | $e->snapshot->create_repository( | ||
| 148 | repository => 'my_backups', | ||
| 149 | type => 'fs', | ||
| 150 | settings => { | ||
| 151 | location => '/mnt/backups' | ||
| 152 | } | ||
| 153 | ); | ||
| 154 | |||
| 155 | $e->snapshot->create( | ||
| 156 | repository => 'my_backups', | ||
| 157 | snapshot => 'backup_2014' | ||
| 158 | ); | ||
| 159 | |||
| 160 | Task management: | ||
| 161 | |||
| 162 | $e->tasks->list; | ||
| 163 | |||
| 164 | `cat` debugging: | ||
| 165 | |||
| 166 | say $e->cat->allocation; | ||
| 167 | say $e->cat->health; | ||
| 168 | |||
| 169 | =head1 DESCRIPTION | ||
| 170 | |||
| 171 | The L<Search::Elasticsearch::Client::5_0::Direct> class provides the | ||
| 172 | Elasticsearch 5.x compatible client returned by: | ||
| 173 | |||
| 174 | $e = Search::Elasticsearch->new( | ||
| 175 | client => "5_0::Direct" # default | ||
| 176 | ); | ||
| 177 | |||
| 178 | It is intended to be as close as possible to the native REST API that | ||
| 179 | Elasticsearch uses, so that it is easy to translate the | ||
| 180 | L<Elasticsearch reference documentation|http://www.elasticsearch/guide> | ||
| 181 | for an API to the equivalent in this client. | ||
| 182 | |||
| 183 | This class provides the methods for L<document CRUD|/DOCUMENT CRUD METHODS>, | ||
| 184 | L<bulk document CRUD|/BULK DOCUMENT CRUD METHODS> and L<search|/SEARCH METHODS>. | ||
| 185 | It also provides access to clients for managing L<indices|/indices()> | ||
| 186 | and the L<cluster|/cluster()>. | ||
| 187 | |||
| 188 | =head1 PREVIOUS VERSIONS OF ELASTICSEARCH | ||
| 189 | |||
| 190 | This version of the client supports the Elasticsearch 5.0 branch, | ||
| 191 | which is not backwards compatible with earlier branches. | ||
| 192 | |||
| 193 | If you need to talk to a version of Elasticsearch before 5.0.0, please | ||
| 194 | install one of the following modules: | ||
| 195 | |||
| 196 | =over | ||
| 197 | |||
| 198 | =item * | ||
| 199 | |||
| 200 | L<Search::Elasticsearch::Client::2_0> | ||
| 201 | |||
| 202 | =item * | ||
| 203 | |||
| 204 | L<Search::Elasticsearch::Client::1_0> | ||
| 205 | |||
| 206 | =item * | ||
| 207 | |||
| 208 | L<Search::Elasticsearch::Client::0_90> | ||
| 209 | |||
| 210 | =back | ||
| 211 | |||
| 212 | =head1 CONVENTIONS | ||
| 213 | |||
| 214 | =head2 Parameter passing | ||
| 215 | |||
| 216 | Parameters can be passed to any request method as a list or as a hash | ||
| 217 | reference. The following two statements are equivalent: | ||
| 218 | |||
| 219 | $e->search( size => 10 ); | ||
| 220 | $e->search({size => 10}); | ||
| 221 | |||
| 222 | =head2 Path parameters | ||
| 223 | |||
| 224 | Any values that should be included in the URL path, eg C</{index}/{type}> | ||
| 225 | should be passed as top level parameters: | ||
| 226 | |||
| 227 | $e->search( index => 'my_index', type => 'my_type' ); | ||
| 228 | |||
| 229 | Alternatively, you can specify a C<path> parameter directly: | ||
| 230 | |||
| 231 | $e->search( path => '/my_index/my_type' ); | ||
| 232 | |||
| 233 | =head2 Query-string parameters | ||
| 234 | |||
| 235 | Any values that should be included in the query string should be passed | ||
| 236 | as top level parameters: | ||
| 237 | |||
| 238 | $e->search( size => 10 ); | ||
| 239 | |||
| 240 | If you pass in a C<\%params> hash, then it will be included in the | ||
| 241 | query string parameters without any error checking. The following: | ||
| 242 | |||
| 243 | $e->search( size => 10, params => { from => 5, size => 5 }) | ||
| 244 | |||
| 245 | would result in this query string: | ||
| 246 | |||
| 247 | ?from=5&size=10 | ||
| 248 | |||
| 249 | =head2 Body parameter | ||
| 250 | |||
| 251 | The request body should be passed in the C<body> key: | ||
| 252 | |||
| 253 | $e->search( | ||
| 254 | body => { | ||
| 255 | query => {...} | ||
| 256 | } | ||
| 257 | ); | ||
| 258 | |||
| 259 | The body can also be a UTF8-decoded string, which will be converted into | ||
| 260 | UTF-8 bytes and passed as is: | ||
| 261 | |||
| 262 | $e->indices->analyze( body => "The quick brown fox"); | ||
| 263 | |||
| 264 | =head2 Filter path parameter | ||
| 265 | |||
| 266 | Any API which returns a JSON body accepts a C<filter_path> parameter | ||
| 267 | which will filter the JSON down to only the specified paths. For instance, | ||
| 268 | if you are running a search request and only want the C<total> hits and | ||
| 269 | the C<_source> field for each hit (without the C<_id>, C<_index> etc), | ||
| 270 | you can do: | ||
| 271 | |||
| 272 | $e->search( | ||
| 273 | query => {...}, | ||
| 274 | filter_path => [ 'hits.total', 'hits.hits._source' ] | ||
| 275 | ); | ||
| 276 | |||
| 277 | =head2 Ignore parameter | ||
| 278 | |||
| 279 | Normally, any HTTP status code outside the 200-299 range will result in | ||
| 280 | an error being thrown. To suppress these errors, you can specify which | ||
| 281 | status codes to ignore in the C<ignore> parameter. | ||
| 282 | |||
| 283 | $e->indices->delete( | ||
| 284 | index => 'my_index', | ||
| 285 | ignore => 404 | ||
| 286 | ); | ||
| 287 | |||
| 288 | This is most useful for | ||
| 289 | L<Missing|Search::Elasticsearch::Error/Search::Elasticsearch::Error::Missing> errors, which | ||
| 290 | are triggered by a C<404> status code when some requested resource does | ||
| 291 | not exist. | ||
| 292 | |||
| 293 | Multiple error codes can be specified with an array: | ||
| 294 | |||
| 295 | $e->indices->delete( | ||
| 296 | index => 'my_index', | ||
| 297 | ignore => [404,409] | ||
| 298 | ); | ||
| 299 | |||
| 300 | =head1 CONFIGURATION | ||
| 301 | |||
| 302 | =head2 C<bulk_helper_class> | ||
| 303 | |||
| 304 | The class to use for the L</bulk_helper()> method. Defaults to | ||
| 305 | L<Search::Elasticsearch::Client::5_0::Bulk>. | ||
| 306 | |||
| 307 | =head2 C<scroll_helper_class> | ||
| 308 | |||
| 309 | The class to use for the L</scroll_helper()> method. Defaults to | ||
| 310 | L<Search::Elasticsearch::Client::5_0::Scroll>. | ||
| 311 | |||
| 312 | =head1 GENERAL METHODS | ||
| 313 | |||
| 314 | =head2 C<info()> | ||
| 315 | |||
| 316 | $info = $e->info | ||
| 317 | |||
| 318 | Returns information about the version of Elasticsearch that the responding node | ||
| 319 | is running. | ||
| 320 | |||
| 321 | =head2 C<ping()> | ||
| 322 | |||
| 323 | $e->ping | ||
| 324 | |||
| 325 | Pings a node in the cluster and returns C<1> if it receives a C<200> | ||
| 326 | response, otherwise it throws an error. | ||
| 327 | |||
| 328 | =head2 C<indices()> | ||
| 329 | |||
| 330 | $indices_client = $e->indices; | ||
| 331 | |||
| 332 | Returns a L<Search::Elasticsearch::Client::5_0::Direct::Indices> object which can be used | ||
| 333 | for managing indices, eg creating, deleting indices, managing mapping, | ||
| 334 | index settings etc. | ||
| 335 | |||
| 336 | =head2 C<ingest()> | ||
| 337 | |||
| 338 | $ingest_client = $e->ingest; | ||
| 339 | |||
| 340 | Returns a L<Search::Elasticsearch::Client::5_0::Direct::Ingest> object which can be used | ||
| 341 | for managing ingest pipelines. | ||
| 342 | |||
| 343 | =head2 C<cluster()> | ||
| 344 | |||
| 345 | $cluster_client = $e->cluster; | ||
| 346 | |||
| 347 | Returns a L<Search::Elasticsearch::Client::5_0::Direct::Cluster> object which can be used | ||
| 348 | for managing the cluster, eg cluster-wide settings and cluster health. | ||
| 349 | |||
| 350 | =head2 C<nodes()> | ||
| 351 | |||
| 352 | $node_client = $e->nodes; | ||
| 353 | |||
| 354 | Returns a L<Search::Elasticsearch::Client::5_0::Direct::Nodes> object which can be used | ||
| 355 | to retrieve node info and stats. | ||
| 356 | |||
| 357 | =head2 C<snapshot()> | ||
| 358 | |||
| 359 | $snapshot_client = $e->snapshot; | ||
| 360 | |||
| 361 | Returns a L<Search::Elasticsearch::Client::5_0::Direct::Snapshot> object which | ||
| 362 | is used for managing backup repositories and creating and restoring | ||
| 363 | snapshots. | ||
| 364 | |||
| 365 | =head2 C<tasks()> | ||
| 366 | |||
| 367 | $tasks_client = $e->tasks; | ||
| 368 | |||
| 369 | Returns a L<Search::Elasticsearch::Client::5_0::Direct::Tasks> object which | ||
| 370 | is used for accessing the task management API. | ||
| 371 | |||
| 372 | =head2 C<cat()> | ||
| 373 | |||
| 374 | $cat_client = $e->cat; | ||
| 375 | |||
| 376 | Returns a L<Search::Elasticsearch::Client::5_0::Direct::Cat> object which can be used | ||
| 377 | to retrieve simple to read text info for debugging and monitoring an | ||
| 378 | Elasticsearch cluster. | ||
| 379 | |||
| 380 | =head1 DOCUMENT CRUD METHODS | ||
| 381 | |||
| 382 | These methods allow you to perform create, index, update and delete requests | ||
| 383 | for single documents: | ||
| 384 | |||
| 385 | =head2 C<index()> | ||
| 386 | |||
| 387 | $response = $e->index( | ||
| 388 | index => 'index_name', # required | ||
| 389 | type => 'type_name', # required | ||
| 390 | id => 'doc_id', # optional, otherwise auto-generated | ||
| 391 | |||
| 392 | body => { document } # required | ||
| 393 | ); | ||
| 394 | |||
| 395 | The C<index()> method is used to index a new document or to reindex | ||
| 396 | an existing document. | ||
| 397 | |||
| 398 | Query string parameters: | ||
| 399 | C<error_trace>, | ||
| 400 | C<human>, | ||
| 401 | C<op_type>, | ||
| 402 | C<parent>, | ||
| 403 | C<pipeline>, | ||
| 404 | C<refresh>, | ||
| 405 | C<routing>, | ||
| 406 | C<timeout>, | ||
| 407 | C<timestamp>, | ||
| 408 | C<ttl>, | ||
| 409 | C<version>, | ||
| 410 | C<version_type>, | ||
| 411 | C<wait_for_active_shards> | ||
| 412 | |||
| 413 | See the L<index docs|http://www.elastic.co/guide/en/elasticsearch/reference/current/docs-index_.html> | ||
| 414 | for more information. | ||
| 415 | |||
| 416 | =head2 C<create()> | ||
| 417 | |||
| 418 | $response = $e->create( | ||
| 419 | index => 'index_name', # required | ||
| 420 | type => 'type_name', # required | ||
| 421 | id => 'doc_id', # required | ||
| 422 | |||
| 423 | body => { document } # required | ||
| 424 | ); | ||
| 425 | |||
| 426 | The C<create()> method works exactly like the L</index()> method, except | ||
| 427 | that it will throw a C<Conflict> error if a document with the same | ||
| 428 | C<index>, C<type> and C<id> already exists. | ||
| 429 | |||
| 430 | Query string parameters: | ||
| 431 | C<consistency>, | ||
| 432 | C<error_trace>, | ||
| 433 | C<human>, | ||
| 434 | C<op_type>, | ||
| 435 | C<parent>, | ||
| 436 | C<refresh>, | ||
| 437 | C<routing>, | ||
| 438 | C<timeout>, | ||
| 439 | C<timestamp>, | ||
| 440 | C<ttl>, | ||
| 441 | C<version>, | ||
| 442 | C<version_type> | ||
| 443 | |||
| 444 | See the L<create docs|http://www.elastic.co/guide/en/elasticsearch/reference/current/docs-create.html> | ||
| 445 | for more information. | ||
| 446 | |||
| 447 | =head2 C<get()> | ||
| 448 | |||
| 449 | $response = $e->get( | ||
| 450 | index => 'index_name', # required | ||
| 451 | type => 'type_name', # required | ||
| 452 | id => 'doc_id', # required | ||
| 453 | ); | ||
| 454 | |||
| 455 | The C<get()> method will retrieve the document with the specified | ||
| 456 | C<index>, C<type> and C<id>, or will throw a C<Missing> error. | ||
| 457 | |||
| 458 | Query string parameters: | ||
| 459 | C<_source>, | ||
| 460 | C<_source_exclude>, | ||
| 461 | C<_source_include>, | ||
| 462 | C<error_trace>, | ||
| 463 | C<human>, | ||
| 464 | C<parent>, | ||
| 465 | C<preference>, | ||
| 466 | C<realtime>, | ||
| 467 | C<refresh>, | ||
| 468 | C<routing>, | ||
| 469 | C<stored_fields>, | ||
| 470 | C<version>, | ||
| 471 | C<version_type> | ||
| 472 | |||
| 473 | See the L<get docs|http://www.elastic.co/guide/en/elasticsearch/reference/current/docs-get.html> | ||
| 474 | for more information. | ||
| 475 | |||
| 476 | =head2 C<get_source()> | ||
| 477 | |||
| 478 | $response = $e->get_source( | ||
| 479 | index => 'index_name', # required | ||
| 480 | type => 'type_name', # required | ||
| 481 | id => 'doc_id', # required | ||
| 482 | ); | ||
| 483 | |||
| 484 | The C<get_source()> method works just like the L</get()> method except that | ||
| 485 | it returns just the C<_source> field (the value of the C<body> parameter | ||
| 486 | in the L</index()> method) instead of returning the C<_source> field | ||
| 487 | plus the document metadata, ie the C<_index>, C<_type> etc. | ||
| 488 | |||
| 489 | Query string parameters: | ||
| 490 | C<_source>, | ||
| 491 | C<_source_exclude>, | ||
| 492 | C<_source_include>, | ||
| 493 | C<error_trace>, | ||
| 494 | C<human>, | ||
| 495 | C<parent>, | ||
| 496 | C<preference>, | ||
| 497 | C<realtime>, | ||
| 498 | C<refresh>, | ||
| 499 | C<routing>, | ||
| 500 | C<version>, | ||
| 501 | C<version_type> | ||
| 502 | |||
| 503 | See the L<get_source docs|http://www.elastic.co/guide/en/elasticsearch/reference/current/docs-get.html> | ||
| 504 | for more information. | ||
| 505 | |||
| 506 | =head2 C<exists()> | ||
| 507 | |||
| 508 | $response = $e->exists( | ||
| 509 | index => 'index_name', # required | ||
| 510 | type => 'type_name', # required | ||
| 511 | id => 'doc_id', # required | ||
| 512 | ); | ||
| 513 | |||
| 514 | The C<exists()> method returns C<1> if a document with the specified | ||
| 515 | C<index>, C<type> and C<id> exists, or an empty string if it doesn't. | ||
| 516 | |||
| 517 | Query string parameters: | ||
| 518 | C<_source>, | ||
| 519 | C<_source_exclude>, | ||
| 520 | C<_source_include>, | ||
| 521 | C<error_trace>, | ||
| 522 | C<human>, | ||
| 523 | C<parent>, | ||
| 524 | C<preference>, | ||
| 525 | C<realtime>, | ||
| 526 | C<refresh>, | ||
| 527 | C<routing>, | ||
| 528 | C<version>, | ||
| 529 | C<version_type> | ||
| 530 | |||
| 531 | See the L<exists docs|http://www.elastic.co/guide/en/elasticsearch/reference/current/docs-get.html> | ||
| 532 | for more information. | ||
| 533 | |||
| 534 | =head2 C<delete()> | ||
| 535 | |||
| 536 | $response = $e->delete( | ||
| 537 | index => 'index_name', # required | ||
| 538 | type => 'type_name', # required | ||
| 539 | id => 'doc_id', # required | ||
| 540 | ); | ||
| 541 | |||
| 542 | The C<delete()> method will delete the document with the specified | ||
| 543 | C<index>, C<type> and C<id>, or will throw a C<Missing> error. | ||
| 544 | |||
| 545 | Query string parameters: | ||
| 546 | C<error_trace>, | ||
| 547 | C<human>, | ||
| 548 | C<parent>, | ||
| 549 | C<refresh>, | ||
| 550 | C<routing>, | ||
| 551 | C<timeout>, | ||
| 552 | C<version>, | ||
| 553 | C<version_type>, | ||
| 554 | C<wait_for_active_shards> | ||
| 555 | |||
| 556 | See the L<delete docs|http://www.elastic.co/guide/en/elasticsearch/reference/current/docs-delete.html> | ||
| 557 | for more information. | ||
| 558 | |||
| 559 | =head2 C<update()> | ||
| 560 | |||
| 561 | $response = $e->update( | ||
| 562 | index => 'index_name', # required | ||
| 563 | type => 'type_name', # required | ||
| 564 | id => 'doc_id', # required | ||
| 565 | |||
| 566 | body => { update } # required | ||
| 567 | ); | ||
| 568 | |||
| 569 | The C<update()> method updates a document with the corresponding | ||
| 570 | C<index>, C<type> and C<id> if it exists. Updates can be performed either by: | ||
| 571 | |||
| 572 | =over | ||
| 573 | |||
| 574 | =item * providing a partial document to be merged in to the existing document: | ||
| 575 | |||
| 576 | $response = $e->update( | ||
| 577 | ..., | ||
| 578 | body => { | ||
| 579 | doc => { new_field => 'new_value'}, | ||
| 580 | } | ||
| 581 | ); | ||
| 582 | |||
| 583 | =item * with an inline script: | ||
| 584 | |||
| 585 | $response = $e->update( | ||
| 586 | ..., | ||
| 587 | body => { | ||
| 588 | script => { | ||
| 589 | inline => "ctx._source.counter += incr", | ||
| 590 | params => { incr => 5 } | ||
| 591 | } | ||
| 592 | } | ||
| 593 | ); | ||
| 594 | |||
| 595 | =item * with an indexed script: | ||
| 596 | |||
| 597 | $response = $e->update( | ||
| 598 | ..., | ||
| 599 | body => { | ||
| 600 | script => { | ||
| 601 | id => $id, | ||
| 602 | lang => 'painless', | ||
| 603 | params => { incr => 5 } | ||
| 604 | } | ||
| 605 | } | ||
| 606 | ); | ||
| 607 | |||
| 608 | See L<indexed scripts|https://www.elastic.co/guide/en/elasticsearch/reference/current/modules-scripting.html#_indexed_scripts> | ||
| 609 | for more information. | ||
| 610 | |||
| 611 | =item * with a script stored as a file: | ||
| 612 | |||
| 613 | $response = $e->update( | ||
| 614 | ..., | ||
| 615 | body => { | ||
| 616 | script => { | ||
| 617 | file => 'counter', | ||
| 618 | lang => 'painless', | ||
| 619 | params => { incr => 5 } | ||
| 620 | } | ||
| 621 | } | ||
| 622 | ); | ||
| 623 | |||
| 624 | See L<scripting docs|https://www.elastic.co/guide/en/elasticsearch/reference/current/modules-scripting.html> | ||
| 625 | for more information. | ||
| 626 | |||
| 627 | =back | ||
| 628 | |||
| 629 | Query string parameters: | ||
| 630 | C<_source>, | ||
| 631 | C<_source_exclude>, | ||
| 632 | C<_source_include>, | ||
| 633 | C<error_trace>, | ||
| 634 | C<fields>, | ||
| 635 | C<human>, | ||
| 636 | C<lang>, | ||
| 637 | C<parent>, | ||
| 638 | C<refresh>, | ||
| 639 | C<retry_on_conflict>, | ||
| 640 | C<routing>, | ||
| 641 | C<timeout>, | ||
| 642 | C<timestamp>, | ||
| 643 | C<ttl>, | ||
| 644 | C<version>, | ||
| 645 | C<version_type>, | ||
| 646 | C<wait_for_active_shards> | ||
| 647 | |||
| 648 | See the L<update docs|http://www.elastic.co/guide/en/elasticsearch/reference/current/docs-update.html> | ||
| 649 | for more information. | ||
| 650 | |||
| 651 | =head2 C<termvectors()> | ||
| 652 | |||
| 653 | $results = $e->termvectors( | ||
| 654 | index => $index, # required | ||
| 655 | type => $type, # required | ||
| 656 | |||
| 657 | id => $id, # optional | ||
| 658 | body => {...} # optional | ||
| 659 | ) | ||
| 660 | |||
| 661 | The C<termvectors()> method retrieves term and field statistics, positions, | ||
| 662 | offsets and payloads for the specified document, assuming that termvectors | ||
| 663 | have been enabled. | ||
| 664 | |||
| 665 | Query string parameters: | ||
| 666 | C<error_trace>, | ||
| 667 | C<field_statistics>, | ||
| 668 | C<fields>, | ||
| 669 | C<human>, | ||
| 670 | C<offsets>, | ||
| 671 | C<parent>, | ||
| 672 | C<payloads>, | ||
| 673 | C<positions>, | ||
| 674 | C<preference>, | ||
| 675 | C<realtime>, | ||
| 676 | C<routing>, | ||
| 677 | C<term_statistics>, | ||
| 678 | C<version>, | ||
| 679 | C<version_type> | ||
| 680 | |||
| 681 | See the L<termvector docs|http://www.elastic.co/guide/en/elasticsearch/reference/current/docs-termvectors.html> | ||
| 682 | for more information. | ||
| 683 | |||
| 684 | =head1 BULK DOCUMENT CRUD METHODS | ||
| 685 | |||
| 686 | The bulk document CRUD methods are used for running multiple CRUD actions | ||
| 687 | within a single request. By reducing the number of network requests | ||
| 688 | that need to be made, bulk requests greatly improve performance. | ||
| 689 | |||
| 690 | =head2 C<bulk()> | ||
| 691 | |||
| 692 | $response = $e->bulk( | ||
| 693 | index => 'index_name', # required if type specified | ||
| 694 | type => 'type_name', # optional | ||
| 695 | |||
| 696 | body => [ actions ] # required | ||
| 697 | ); | ||
| 698 | |||
| 699 | See L<Search::Elasticsearch::Client::5_0::Bulk> and L</bulk_helper()> for a helper module that makes | ||
| 700 | bulk indexing simpler to use. | ||
| 701 | |||
| 702 | The C<bulk()> method can perform multiple L</index()>, L</create()>, | ||
| 703 | L</delete()> or L</update()> actions with a single request. The C<body> | ||
| 704 | parameter expects an array containing the list of actions to perform. | ||
| 705 | |||
| 706 | An I<action> consists of an initial metadata hash ref containing the action | ||
| 707 | type, plus the associated metadata, eg : | ||
| 708 | |||
| 709 | { delete => { _index => 'index', _type => 'type', _id => 123 }} | ||
| 710 | |||
| 711 | The C<index> and C<create> actions then expect a hashref containing | ||
| 712 | the document itself: | ||
| 713 | |||
| 714 | { create => { _index => 'index', _type => 'type', _id => 123 }}, | ||
| 715 | { title => "A newly created document" } | ||
| 716 | |||
| 717 | And the C<update> action expects a hashref containing the update commands, | ||
| 718 | eg: | ||
| 719 | |||
| 720 | { update => { _index => 'index', _type => 'type', _id => 123 }}, | ||
| 721 | { script => "ctx._source.counter+=1" } | ||
| 722 | |||
| 723 | Each action can include the same parameters that you would pass to | ||
| 724 | the equivalent L</index()>, L</create()>, L</delete()> or L</update()> | ||
| 725 | request, except that C<_index>, C<_type> and C<_id> must be specified with | ||
| 726 | the preceding underscore. All other parameters can be specified with or | ||
| 727 | without the underscore. | ||
| 728 | |||
| 729 | For instance: | ||
| 730 | |||
| 731 | $response = $e->bulk( | ||
| 732 | index => 'index_name', # default index name | ||
| 733 | type => 'type_name', # default type name | ||
| 734 | body => [ | ||
| 735 | |||
| 736 | # create action | ||
| 737 | { create => { | ||
| 738 | _index => 'not_the_default_index', | ||
| 739 | _type => 'not_the_default_type', | ||
| 740 | _id => 123 | ||
| 741 | }}, | ||
| 742 | { title => 'Foo' }, | ||
| 743 | |||
| 744 | # index action | ||
| 745 | { index => { _id => 124 }}, | ||
| 746 | { title => 'Foo' }, | ||
| 747 | |||
| 748 | # delete action | ||
| 749 | { delete => { _id => 125 }}, | ||
| 750 | |||
| 751 | # update action | ||
| 752 | { update => { _id => 126 }}, | ||
| 753 | { script => "ctx._source.counter+1" } | ||
| 754 | ] | ||
| 755 | ); | ||
| 756 | |||
| 757 | Each action is performed separately. One failed action will not | ||
| 758 | cause the others to fail as well. | ||
| 759 | |||
| 760 | Query string parameters: | ||
| 761 | C<_source>, | ||
| 762 | C<_source_exclude>, | ||
| 763 | C<_source_include>, | ||
| 764 | C<error_trace>, | ||
| 765 | C<fields>, | ||
| 766 | C<human>, | ||
| 767 | C<pipeline>, | ||
| 768 | C<refresh>, | ||
| 769 | C<routing>, | ||
| 770 | C<timeout>, | ||
| 771 | C<wait_for_active_shards> | ||
| 772 | |||
| 773 | See the L<bulk docs|http://www.elastic.co/guide/en/elasticsearch/reference/current/docs-bulk.html> | ||
| 774 | for more information. | ||
| 775 | |||
| 776 | =head2 C<bulk_helper()> | ||
| 777 | |||
| 778 | $bulk_helper = $e->bulk_helper( @args ); | ||
| 779 | |||
| 780 | Returns a new instance of the class specified in the L</bulk_helper_class>, | ||
| 781 | which defaults to L<Search::Elasticsearch::Client::5_0::Bulk>. | ||
| 782 | |||
| 783 | =head2 C<mget()> | ||
| 784 | |||
| 785 | $results = $e->mget( | ||
| 786 | index => 'default_index', # optional, required when type specified | ||
| 787 | type => 'default_type', # optional | ||
| 788 | |||
| 789 | body => { docs or ids } # required | ||
| 790 | ); | ||
| 791 | |||
| 792 | The C<mget()> method will retrieve multiple documents with a single request. | ||
| 793 | The C<body> consists of an array of documents to retrieve: | ||
| 794 | |||
| 795 | $results = $e->mget( | ||
| 796 | index => 'default_index', | ||
| 797 | type => 'default_type', | ||
| 798 | body => { | ||
| 799 | docs => [ | ||
| 800 | { _id => 1}, | ||
| 801 | { _id => 2, _type => 'not_the_default_type' } | ||
| 802 | ] | ||
| 803 | } | ||
| 804 | ); | ||
| 805 | |||
| 806 | You can also pass any of the other parameters that the L</get()> request | ||
| 807 | accepts. | ||
| 808 | |||
| 809 | If you have specified an C<index> and C<type>, you can just include the | ||
| 810 | C<ids> of the documents to retrieve: | ||
| 811 | |||
| 812 | $results = $e->mget( | ||
| 813 | index => 'default_index', | ||
| 814 | type => 'default_type', | ||
| 815 | body => { | ||
| 816 | ids => [ 1, 2, 3] | ||
| 817 | } | ||
| 818 | ); | ||
| 819 | |||
| 820 | Query string parameters: | ||
| 821 | C<_source>, | ||
| 822 | C<_source_exclude>, | ||
| 823 | C<_source_include>, | ||
| 824 | C<error_trace>, | ||
| 825 | C<human>, | ||
| 826 | C<preference>, | ||
| 827 | C<realtime>, | ||
| 828 | C<refresh>, | ||
| 829 | C<routing>, | ||
| 830 | C<stored_fields> | ||
| 831 | |||
| 832 | See the L<mget docs|http://www.elastic.co/guide/en/elasticsearch/reference/current/docs-multi-get.html> | ||
| 833 | for more information. | ||
| 834 | |||
| 835 | =head2 C<mtermvectors()> | ||
| 836 | |||
| 837 | $results = $e->mtermvectors( | ||
| 838 | index => $index, # required if type specified | ||
| 839 | type => $type, # optional | ||
| 840 | |||
| 841 | body => { } # optional | ||
| 842 | ) | ||
| 843 | |||
| 844 | Runs multiple L</termvector()> requests in a single request, eg: | ||
| 845 | |||
| 846 | $results = $e->mtermvectors( | ||
| 847 | index => 'test', | ||
| 848 | body => { | ||
| 849 | docs => [ | ||
| 850 | { _type => 'test', _id => 1, fields => ['text'] }, | ||
| 851 | { _type => 'test', _id => 2, payloads => 1 }, | ||
| 852 | ] | ||
| 853 | } | ||
| 854 | ); | ||
| 855 | |||
| 856 | Query string parameters: | ||
| 857 | C<error_trace>, | ||
| 858 | C<field_statistics>, | ||
| 859 | C<fields>, | ||
| 860 | C<human>, | ||
| 861 | C<ids>, | ||
| 862 | C<offsets>, | ||
| 863 | C<parent>, | ||
| 864 | C<payloads>, | ||
| 865 | C<positions>, | ||
| 866 | C<preference>, | ||
| 867 | C<realtime>, | ||
| 868 | C<routing>, | ||
| 869 | C<term_statistics>, | ||
| 870 | C<version>, | ||
| 871 | C<version_type> | ||
| 872 | |||
| 873 | See the L<mtermvectors docs|http://www.elastic.co/guide/en/elasticsearch/reference/current/docs-multi-termvectors.html> | ||
| 874 | for more information. | ||
| 875 | |||
| 876 | =head1 SEARCH METHODS | ||
| 877 | |||
| 878 | The search methods are used for querying documents in one, more or all indices | ||
| 879 | and of one, more or all types: | ||
| 880 | |||
| 881 | =head2 C<search()> | ||
| 882 | |||
| 883 | $results = $e->search( | ||
| 884 | index => 'index' | \@indices, # optional | ||
| 885 | type => 'type' | \@types, # optional | ||
| 886 | |||
| 887 | body => { search params } # optional | ||
| 888 | ); | ||
| 889 | |||
| 890 | The C<search()> method searches for matching documents in one or more | ||
| 891 | indices. It is just as easy to search a single index as it is to search | ||
| 892 | all the indices in your cluster. It can also return | ||
| 893 | L<aggregations|http://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations.html> | ||
| 894 | L<highlighted snippets|http://www.elastic.co/guide/en/elasticsearch/reference/current/search-highlighting.html> | ||
| 895 | and L<did-you-mean|http://www.elastic.co/guide/en/elasticsearch/reference/current/search-suggesters-phrase.html> | ||
| 896 | or L<search-as-you-type|http://www.elastic.co/guide/en/elasticsearch/reference/current/search-suggesters-completion.html> | ||
| 897 | suggestions. | ||
| 898 | |||
| 899 | The I<lite> L<version of search|http://www.elastic.co/guide/en/elasticsearch/reference/current/search-uri-request.html> | ||
| 900 | allows you to specify a query string in the C<q> parameter, using the | ||
| 901 | Lucene query string syntax: | ||
| 902 | |||
| 903 | $results = $e->search( q => 'title:(elasticsearch clients)'); | ||
| 904 | |||
| 905 | However, the preferred way to search is by using the | ||
| 906 | L<Query DSL|http://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl.html> | ||
| 907 | to create a query, and passing that C<query> in the | ||
| 908 | L<request body|http://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-body.html>: | ||
| 909 | |||
| 910 | $results = $e->search( | ||
| 911 | body => { | ||
| 912 | query => { | ||
| 913 | match => { title => 'Elasticsearch clients'} | ||
| 914 | } | ||
| 915 | } | ||
| 916 | ); | ||
| 917 | |||
| 918 | Query string parameters: | ||
| 919 | C<_source>, | ||
| 920 | C<_source_exclude>, | ||
| 921 | C<_source_include>, | ||
| 922 | C<allow_no_indices>, | ||
| 923 | C<analyze_wildcard>, | ||
| 924 | C<analyzer>, | ||
| 925 | C<batched_reduce_size>, | ||
| 926 | C<default_operator>, | ||
| 927 | C<df>, | ||
| 928 | C<docvalue_fields>, | ||
| 929 | C<error_trace>, | ||
| 930 | C<expand_wildcards>, | ||
| 931 | C<explain>, | ||
| 932 | C<fielddata_fields>, | ||
| 933 | C<from>, | ||
| 934 | C<human>, | ||
| 935 | C<ignore_unavailable>, | ||
| 936 | C<lenient>, | ||
| 937 | C<max_concurrent_shard_requests>, | ||
| 938 | C<pre_filter_shard_size>, | ||
| 939 | C<preference>, | ||
| 940 | C<q>, | ||
| 941 | C<request_cache>, | ||
| 942 | C<routing>, | ||
| 943 | C<scroll>, | ||
| 944 | C<search_type>, | ||
| 945 | C<size>, | ||
| 946 | C<sort>, | ||
| 947 | C<stats>, | ||
| 948 | C<stored_fields>, | ||
| 949 | C<suggest_field>, | ||
| 950 | C<suggest_mode>, | ||
| 951 | C<suggest_size>, | ||
| 952 | C<suggest_text>, | ||
| 953 | C<terminate_after>, | ||
| 954 | C<timeout>, | ||
| 955 | C<track_scores>, | ||
| 956 | C<typed_keys>, | ||
| 957 | C<version> | ||
| 958 | |||
| 959 | See the L<search reference|http://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-body.html> | ||
| 960 | for more information. | ||
| 961 | |||
| 962 | Also see L<Search::Elasticsearch::Transport/send_get_body_as>. | ||
| 963 | |||
| 964 | =head2 C<count()> | ||
| 965 | |||
| 966 | $results = $e->count( | ||
| 967 | index => 'index' | \@indices, # optional | ||
| 968 | type => 'type' | \@types, # optional | ||
| 969 | |||
| 970 | body => { query } # optional | ||
| 971 | ) | ||
| 972 | |||
| 973 | The C<count()> method returns the total count of all documents matching the | ||
| 974 | query: | ||
| 975 | |||
| 976 | $results = $e->count( | ||
| 977 | body => { | ||
| 978 | query => { | ||
| 979 | match => { title => 'Elasticsearch clients' } | ||
| 980 | } | ||
| 981 | } | ||
| 982 | ); | ||
| 983 | |||
| 984 | Query string parameters: | ||
| 985 | C<allow_no_indices>, | ||
| 986 | C<analyze_wildcard>, | ||
| 987 | C<analyzer>, | ||
| 988 | C<default_operator>, | ||
| 989 | C<df>, | ||
| 990 | C<error_trace>, | ||
| 991 | C<expand_wildcards>, | ||
| 992 | C<human>, | ||
| 993 | C<ignore_unavailable>, | ||
| 994 | C<lenient>, | ||
| 995 | C<lowercase_expanded_terms> | ||
| 996 | C<min_score>, | ||
| 997 | C<preference>, | ||
| 998 | C<q>, | ||
| 999 | C<routing>, | ||
| 1000 | C<terminate_after> | ||
| 1001 | |||
| 1002 | See the L<count docs|http://www.elastic.co/guide/en/elasticsearch/reference/current/search-count.html> | ||
| 1003 | for more information. | ||
| 1004 | |||
| 1005 | =head2 C<search_template()> | ||
| 1006 | |||
| 1007 | $results = $e->search_template( | ||
| 1008 | index => 'index' | \@indices, # optional | ||
| 1009 | type => 'type' | \@types, # optional | ||
| 1010 | |||
| 1011 | body => { search params } # optional | ||
| 1012 | ); | ||
| 1013 | |||
| 1014 | Perform a search by specifying a template (either predefined or defined | ||
| 1015 | within the C<body>) and parameters to use with the template, eg: | ||
| 1016 | |||
| 1017 | $results = $e->search_template( | ||
| 1018 | body => { | ||
| 1019 | inline => { | ||
| 1020 | query => { | ||
| 1021 | match => { | ||
| 1022 | "{{my_field}}" => "{{my_value}}" | ||
| 1023 | } | ||
| 1024 | }, | ||
| 1025 | size => "{{my_size}}" | ||
| 1026 | }, | ||
| 1027 | params => { | ||
| 1028 | my_field => 'foo', | ||
| 1029 | my_value => 'bar', | ||
| 1030 | my_size => 5 | ||
| 1031 | } | ||
| 1032 | } | ||
| 1033 | ); | ||
| 1034 | |||
| 1035 | See the L<search template docs|http://www.elastic.co/guide/en/elasticsearch/reference/current/search-template.html> | ||
| 1036 | for more information. | ||
| 1037 | |||
| 1038 | Query string parameters: | ||
| 1039 | C<allow_no_indices>, | ||
| 1040 | C<error_trace>, | ||
| 1041 | C<expand_wildcards>, | ||
| 1042 | C<explain>, | ||
| 1043 | C<human>, | ||
| 1044 | C<ignore_unavailable>, | ||
| 1045 | C<preference>, | ||
| 1046 | C<profile>, | ||
| 1047 | C<scroll>, | ||
| 1048 | C<search_type>, | ||
| 1049 | C<typed_keys> | ||
| 1050 | |||
| 1051 | =head2 C<render_search_template()> | ||
| 1052 | |||
| 1053 | $response = $e->render_search_template( | ||
| 1054 | id => 'id', # optional | ||
| 1055 | body => { template } # optional | ||
| 1056 | ); | ||
| 1057 | |||
| 1058 | Renders the template, filling in the passed-in parameters and returns the resulting JSON, eg: | ||
| 1059 | |||
| 1060 | $results = $e->render_search_template( | ||
| 1061 | body => { | ||
| 1062 | inline => { | ||
| 1063 | query => { | ||
| 1064 | match => { | ||
| 1065 | "{{my_field}}" => "{{my_value}}" | ||
| 1066 | } | ||
| 1067 | }, | ||
| 1068 | size => "{{my_size}}" | ||
| 1069 | }, | ||
| 1070 | params => { | ||
| 1071 | my_field => 'foo', | ||
| 1072 | my_value => 'bar', | ||
| 1073 | my_size => 5 | ||
| 1074 | } | ||
| 1075 | } | ||
| 1076 | ); | ||
| 1077 | |||
| 1078 | See the L<search template docs|http://www.elastic.co/guide/en/elasticsearch/reference/current/search-template.html> | ||
| 1079 | for more information. | ||
| 1080 | |||
| 1081 | =head2 C<scroll()> | ||
| 1082 | |||
| 1083 | $results = $e->scroll( | ||
| 1084 | scroll => '1m', | ||
| 1085 | body => { | ||
| 1086 | scroll_id => $id | ||
| 1087 | } | ||
| 1088 | ); | ||
| 1089 | |||
| 1090 | When a L</search()> has been performed with the | ||
| 1091 | C<scroll> parameter, the C<scroll()> | ||
| 1092 | method allows you to keep pulling more results until the results | ||
| 1093 | are exhausted. | ||
| 1094 | |||
| 1095 | See L</scroll_helper()> and L<Search::Elasticsearch::Client::5_0::Scroll> for a helper utility | ||
| 1096 | which makes managing scroll requests much easier. | ||
| 1097 | |||
| 1098 | Query string parameters: | ||
| 1099 | C<error_trace>, | ||
| 1100 | C<human>, | ||
| 1101 | C<scroll>, | ||
| 1102 | C<scroll_id> | ||
| 1103 | |||
| 1104 | See the L<scroll docs|http://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-scroll.html> | ||
| 1105 | and the L<search_type docs|http://www.elastic.co/guide/en/elasticsearch/reference/current/search.html/search-request-search-type.html> | ||
| 1106 | for more information. | ||
| 1107 | |||
| 1108 | =head2 C<clear_scroll()> | ||
| 1109 | |||
| 1110 | $response = $e->clear_scroll( | ||
| 1111 | body => { | ||
| 1112 | scroll_id => $id | \@ids # required | ||
| 1113 | } | ||
| 1114 | ); | ||
| 1115 | |||
| 1116 | The C<clear_scroll()> method can clear unfinished scroll requests, freeing | ||
| 1117 | up resources on the server. | ||
| 1118 | |||
| 1119 | =head2 C<scroll_helper()> | ||
| 1120 | |||
| 1121 | $scroll_helper = $e->scroll_helper( @args ); | ||
| 1122 | |||
| 1123 | Returns a new instance of the class specified in the L</scroll_helper_class>, | ||
| 1124 | which defaults to L<Search::Elasticsearch::Client::5_0::Scroll>. | ||
| 1125 | |||
| 1126 | =head2 C<msearch()> | ||
| 1127 | |||
| 1128 | $results = $e->msearch( | ||
| 1129 | index => 'default_index' | \@indices, # optional | ||
| 1130 | type => 'default_type' | \@types, # optional | ||
| 1131 | |||
| 1132 | body => [ searches ] # required | ||
| 1133 | ); | ||
| 1134 | |||
| 1135 | The C<msearch()> method allows you to perform multiple searches in a single | ||
| 1136 | request. Similar to the L</bulk()> request, each search request in the | ||
| 1137 | C<body> consists of two hashes: the metadata hash then the search request | ||
| 1138 | hash (the same data that you'd specify in the C<body> of a L</search()> | ||
| 1139 | request). For instance: | ||
| 1140 | |||
| 1141 | $results = $e->msearch( | ||
| 1142 | index => 'default_index', | ||
| 1143 | type => ['default_type_1', 'default_type_2'], | ||
| 1144 | body => [ | ||
| 1145 | # uses defaults | ||
| 1146 | {}, | ||
| 1147 | { query => { match_all => {} }}, | ||
| 1148 | |||
| 1149 | # uses a custom index | ||
| 1150 | { index => 'not_the_default_index' }, | ||
| 1151 | { query => { match_all => {} }} | ||
| 1152 | ] | ||
| 1153 | ); | ||
| 1154 | |||
| 1155 | Query string parameters: | ||
| 1156 | C<error_trace>, | ||
| 1157 | C<human>, | ||
| 1158 | C<max_concurrent_searches>, | ||
| 1159 | C<pre_filter_shard_size>, | ||
| 1160 | C<search_type>, | ||
| 1161 | C<typed_keys> | ||
| 1162 | |||
| 1163 | See the L<msearch docs|http://www.elastic.co/guide/en/elasticsearch/reference/current/search-multi-search.html> | ||
| 1164 | for more information. | ||
| 1165 | |||
| 1166 | =head2 C<msearch_template()> | ||
| 1167 | |||
| 1168 | $results = $e->msearch_template( | ||
| 1169 | index => 'default_index' | \@indices, # optional | ||
| 1170 | type => 'default_type' | \@types, # optional | ||
| 1171 | |||
| 1172 | body => [ search_templates ] # required | ||
| 1173 | ); | ||
| 1174 | |||
| 1175 | The C<msearch_template()> method allows you to perform multiple searches in a single | ||
| 1176 | request using search templates. Similar to the L</bulk()> request, each search | ||
| 1177 | request in the C<body> consists of two hashes: the metadata hash then the search request | ||
| 1178 | hash (the same data that you'd specify in the C<body> of a L</search()> | ||
| 1179 | request). For instance: | ||
| 1180 | |||
| 1181 | $results = $e->msearch( | ||
| 1182 | index => 'default_index', | ||
| 1183 | type => ['default_type_1', 'default_type_2'], | ||
| 1184 | body => [ | ||
| 1185 | # uses defaults | ||
| 1186 | {}, | ||
| 1187 | { inline => { query => { match => { user => "{{user}}" }}} params => { user => 'joe' }}, | ||
| 1188 | |||
| 1189 | # uses a custom index | ||
| 1190 | { index => 'not_the_default_index' }, | ||
| 1191 | { inline => { query => { match => { user => "{{user}}" }}} params => { user => 'joe' }}, | ||
| 1192 | ] | ||
| 1193 | ); | ||
| 1194 | |||
| 1195 | Query string parameters: | ||
| 1196 | C<error_trace>, | ||
| 1197 | C<human>, | ||
| 1198 | C<max_concurrent_searches>, | ||
| 1199 | C<search_type>, | ||
| 1200 | C<typed_keys> | ||
| 1201 | |||
| 1202 | See the L<msearch-template docs|http://www.elastic.co/guide/en/elasticsearch/reference/current/multi-search-template.html> | ||
| 1203 | for more information. | ||
| 1204 | |||
| 1205 | =head2 C<explain()> | ||
| 1206 | |||
| 1207 | $response = $e->explain( | ||
| 1208 | index => 'my_index', # required | ||
| 1209 | type => 'my_type', # required | ||
| 1210 | id => 123, # required | ||
| 1211 | |||
| 1212 | body => { search } # required | ||
| 1213 | ); | ||
| 1214 | |||
| 1215 | The C<explain()> method explains why the specified document did or | ||
| 1216 | did not match a query, and how the relevance score was calculated. | ||
| 1217 | For instance: | ||
| 1218 | |||
| 1219 | $response = $e->explain( | ||
| 1220 | index => 'my_index', | ||
| 1221 | type => 'my_type', | ||
| 1222 | id => 123, | ||
| 1223 | body => { | ||
| 1224 | query => { | ||
| 1225 | match => { title => 'Elasticsearch clients' } | ||
| 1226 | } | ||
| 1227 | } | ||
| 1228 | ); | ||
| 1229 | |||
| 1230 | Query string parameters: | ||
| 1231 | C<_source>, | ||
| 1232 | C<_source_exclude>, | ||
| 1233 | C<_source_include>, | ||
| 1234 | C<analyze_wildcard>, | ||
| 1235 | C<analyzer>, | ||
| 1236 | C<default_operator>, | ||
| 1237 | C<df>, | ||
| 1238 | C<error_trace>, | ||
| 1239 | C<human>, | ||
| 1240 | C<lenient>, | ||
| 1241 | C<parent>, | ||
| 1242 | C<preference>, | ||
| 1243 | C<q>, | ||
| 1244 | C<routing>, | ||
| 1245 | C<stored_fields> | ||
| 1246 | |||
| 1247 | See the L<explain docs|http://www.elastic.co/guide/en/elasticsearch/reference/current/search-explain.html> | ||
| 1248 | for more information. | ||
| 1249 | |||
| 1250 | =head2 C<field_caps()> | ||
| 1251 | |||
| 1252 | $response = $e->field_caps( | ||
| 1253 | index => 'index' | \@indices, # optional | ||
| 1254 | body => { filters } # optional | ||
| 1255 | ); | ||
| 1256 | |||
| 1257 | The C<field-caps> API returns field types and abilities, merged across indices. | ||
| 1258 | |||
| 1259 | Query string parameters: | ||
| 1260 | C<allow_no_indices>, | ||
| 1261 | C<error_trace>, | ||
| 1262 | C<expand_wildcards>, | ||
| 1263 | C<fields>, | ||
| 1264 | C<human>, | ||
| 1265 | C<ignore_unavailable> | ||
| 1266 | |||
| 1267 | See the L<field-caps docs|http://www.elastic.co/guide/en/elasticsearch/reference/current/search-field-caps.html> | ||
| 1268 | for more information. | ||
| 1269 | |||
| 1270 | =head2 C<field_stats()> | ||
| 1271 | |||
| 1272 | $response = $e->field_stats( | ||
| 1273 | index => 'index' | \@indices, # optional | ||
| 1274 | fields => 'field' | \@fields, # optional | ||
| 1275 | level => 'cluster' | 'indices', # optional | ||
| 1276 | body => { filters } # optional | ||
| 1277 | ); | ||
| 1278 | |||
| 1279 | The C<field-stats> API returns statistical properties of a field | ||
| 1280 | (such as min and max values) without executing a search. | ||
| 1281 | |||
| 1282 | Query string parameters: | ||
| 1283 | C<allow_no_indices>, | ||
| 1284 | C<error_trace>, | ||
| 1285 | C<expand_wildcards>, | ||
| 1286 | C<fields>, | ||
| 1287 | C<human>, | ||
| 1288 | C<ignore_unavailable>, | ||
| 1289 | C<level> | ||
| 1290 | |||
| 1291 | See the L<field-stats docs|http://www.elastic.co/guide/en/elasticsearch/reference/current/search-field-stats.html> | ||
| 1292 | for more information. | ||
| 1293 | |||
| 1294 | =head2 C<search_shards()> | ||
| 1295 | |||
| 1296 | $response = $e->search_shards( | ||
| 1297 | index => 'index' | \@indices, # optional | ||
| 1298 | type => 'type' | \@types, # optional | ||
| 1299 | ) | ||
| 1300 | |||
| 1301 | The C<search_shards()> method returns information about which shards on | ||
| 1302 | which nodes will execute a search request. | ||
| 1303 | |||
| 1304 | Query string parameters: | ||
| 1305 | C<allow_no_indices>, | ||
| 1306 | C<error_trace>, | ||
| 1307 | C<expand_wildcards>, | ||
| 1308 | C<human>, | ||
| 1309 | C<ignore_unavailable>, | ||
| 1310 | C<local>, | ||
| 1311 | C<preference>, | ||
| 1312 | C<routing> | ||
| 1313 | |||
| 1314 | See the L<search-shards docs|http://www.elastic.co/guide/en/elasticsearch/reference/current/search-shards.html> | ||
| 1315 | for more information. | ||
| 1316 | |||
| 1317 | =head1 CRUD-BY-QUERY METHODS | ||
| 1318 | |||
| 1319 | =head2 C<delete_by_query()> | ||
| 1320 | |||
| 1321 | $response = $e->delete_by_query( | ||
| 1322 | index => 'index' | \@indices, # optional | ||
| 1323 | type => 'type' | \@types, # optional, | ||
| 1324 | body => { delete-by-query } # required | ||
| 1325 | ); | ||
| 1326 | |||
| 1327 | The C<delete_by_query()> method deletes all documents which match the specified query. | ||
| 1328 | |||
| 1329 | Query string parameters: | ||
| 1330 | C<_source>, | ||
| 1331 | C<_source_exclude>, | ||
| 1332 | C<_source_include>, | ||
| 1333 | C<allow_no_indices>, | ||
| 1334 | C<analyze_wildcard>, | ||
| 1335 | C<analyzer>, | ||
| 1336 | C<conflicts>, | ||
| 1337 | C<default_operator>, | ||
| 1338 | C<df>, | ||
| 1339 | C<error_trace>, | ||
| 1340 | C<expand_wildcards>, | ||
| 1341 | C<from>, | ||
| 1342 | C<human>, | ||
| 1343 | C<ignore_unavailable>, | ||
| 1344 | C<lenient>, | ||
| 1345 | C<preference>, | ||
| 1346 | C<q>, | ||
| 1347 | C<refresh>, | ||
| 1348 | C<request_cache>, | ||
| 1349 | C<requests_per_second>, | ||
| 1350 | C<routing>, | ||
| 1351 | C<scroll>, | ||
| 1352 | C<scroll_size>, | ||
| 1353 | C<search_timeout>, | ||
| 1354 | C<search_type>, | ||
| 1355 | C<size>, | ||
| 1356 | C<slices>, | ||
| 1357 | C<sort>, | ||
| 1358 | C<stats>, | ||
| 1359 | C<terminate_after>, | ||
| 1360 | C<version>, | ||
| 1361 | C<timeout>, | ||
| 1362 | C<wait_for_active_shards>, | ||
| 1363 | C<wait_for_completion> | ||
| 1364 | |||
| 1365 | See the L<delete-by-query docs|https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-delete-by-query.html> | ||
| 1366 | for more information. | ||
| 1367 | |||
| 1368 | =head2 C<reindex()> | ||
| 1369 | |||
| 1370 | $response = $e->reindex( | ||
| 1371 | body => { reindex } # required | ||
| 1372 | ); | ||
| 1373 | |||
| 1374 | The C<reindex()> API is used to index documents from one index or multiple indices | ||
| 1375 | to a new index. | ||
| 1376 | |||
| 1377 | Query string parameters: | ||
| 1378 | C<error_trace>, | ||
| 1379 | C<human>, | ||
| 1380 | C<refresh>, | ||
| 1381 | C<requests_per_second>, | ||
| 1382 | C<slices>, | ||
| 1383 | C<timeout>, | ||
| 1384 | C<wait_for_active_shards>, | ||
| 1385 | C<wait_for_completion> | ||
| 1386 | |||
| 1387 | See the L<reindex docs|https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-reindex.html> | ||
| 1388 | for more information. | ||
| 1389 | |||
| 1390 | =head2 C<update_by_query()> | ||
| 1391 | |||
| 1392 | $response = $e->update_by_query( | ||
| 1393 | index => 'index' | \@indices, # optional | ||
| 1394 | type => 'type' | \@types, # optional, | ||
| 1395 | body => { update-by-query } # optional | ||
| 1396 | ); | ||
| 1397 | |||
| 1398 | The C<update_by_query()> API is used to bulk update documents from one index or | ||
| 1399 | multiple indices using a script. | ||
| 1400 | |||
| 1401 | Query string parameters: | ||
| 1402 | C<_source>, | ||
| 1403 | C<_source_exclude>, | ||
| 1404 | C<_source_include>, | ||
| 1405 | C<allow_no_indices>, | ||
| 1406 | C<analyze_wildcard>, | ||
| 1407 | C<analyzer>, | ||
| 1408 | C<conflicts>, | ||
| 1409 | C<default_operator>, | ||
| 1410 | C<df>, | ||
| 1411 | C<error_trace>, | ||
| 1412 | C<expand_wildcards>, | ||
| 1413 | C<from>, | ||
| 1414 | C<human>, | ||
| 1415 | C<ignore_unavailable>, | ||
| 1416 | C<lenient>, | ||
| 1417 | C<pipeline>, | ||
| 1418 | C<preference>, | ||
| 1419 | C<q>, | ||
| 1420 | C<refresh>, | ||
| 1421 | C<request_cache>, | ||
| 1422 | C<requests_per_second>, | ||
| 1423 | C<routing>, | ||
| 1424 | C<scroll>, | ||
| 1425 | C<scroll_size>, | ||
| 1426 | C<search_timeout>, | ||
| 1427 | C<search_type>, | ||
| 1428 | C<size>, | ||
| 1429 | C<slices>, | ||
| 1430 | C<sort>, | ||
| 1431 | C<stats>, | ||
| 1432 | C<terminate_after>, | ||
| 1433 | C<timeout>, | ||
| 1434 | C<version>, | ||
| 1435 | C<version_type>, | ||
| 1436 | C<wait_for_active_shards>, | ||
| 1437 | C<wait_for_completion> | ||
| 1438 | |||
| 1439 | See the L<update_by_query docs|https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-update-by-query.html> | ||
| 1440 | for more information. | ||
| 1441 | |||
| 1442 | =head2 C<reindex_rethrottle> | ||
| 1443 | |||
| 1444 | $response = $e->reindex_rethrottle( | ||
| 1445 | task_id => 'task_id', # required | ||
| 1446 | requests_per_second => $req_per_second | ||
| 1447 | ); | ||
| 1448 | |||
| 1449 | The C<reindex_rethrottle()> API is used to dynamically update the throtting | ||
| 1450 | of an existing reindex request, identified by C<task_id>. | ||
| 1451 | |||
| 1452 | Query string parameters: | ||
| 1453 | C<error_trace>, | ||
| 1454 | C<human>, | ||
| 1455 | C<requests_per_second> | ||
| 1456 | |||
| 1457 | See the L<reindex docs|https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-reindex.html> | ||
| 1458 | for more information. | ||
| 1459 | |||
| 1460 | =head1 PERCOLATION METHODS | ||
| 1461 | |||
| 1462 | =head2 C<percolate()> | ||
| 1463 | |||
| 1464 | $results = $e->percolate( | ||
| 1465 | index => 'my_index', # required | ||
| 1466 | type => 'my_type', # required | ||
| 1467 | |||
| 1468 | body => { percolation } # required | ||
| 1469 | ); | ||
| 1470 | |||
| 1471 | Percolation is search inverted: instead of finding docs which match a | ||
| 1472 | particular query, it finds queries which match a particular document, eg | ||
| 1473 | for I<alert-me-when> functionality. | ||
| 1474 | |||
| 1475 | The C<percolate()> method runs a percolation request to find the | ||
| 1476 | queries matching a particular document. In the C<body> you should pass the | ||
| 1477 | C<_source> field of the document under the C<doc> key: | ||
| 1478 | |||
| 1479 | $results = $e->percolate( | ||
| 1480 | index => 'my_index', | ||
| 1481 | type => 'my_type', | ||
| 1482 | body => { | ||
| 1483 | doc => { | ||
| 1484 | title => 'Elasticsearch rocks' | ||
| 1485 | } | ||
| 1486 | } | ||
| 1487 | ); | ||
| 1488 | |||
| 1489 | Query string parameters: | ||
| 1490 | C<allow_no_indices>, | ||
| 1491 | C<error_trace>, | ||
| 1492 | C<expand_wildcards>, | ||
| 1493 | C<human>, | ||
| 1494 | C<ignore_unavailable>, | ||
| 1495 | C<percolate_format>, | ||
| 1496 | C<percolate_index>, | ||
| 1497 | C<percolate_preference>, | ||
| 1498 | C<percolate_routing>, | ||
| 1499 | C<percolate_type>, | ||
| 1500 | C<preference>, | ||
| 1501 | C<routing>, | ||
| 1502 | C<version>, | ||
| 1503 | C<version_type> | ||
| 1504 | |||
| 1505 | See the L<percolate docs|http://www.elastic.co/guide/en/elasticsearch/reference/current/search-percolate.html> | ||
| 1506 | for more information. | ||
| 1507 | |||
| 1508 | =head2 C<count_percolate()> | ||
| 1509 | |||
| 1510 | $results = $e->count_percolate( | ||
| 1511 | index => 'my_index', # required | ||
| 1512 | type => 'my_type', # required | ||
| 1513 | |||
| 1514 | body => { percolation } # required | ||
| 1515 | ); | ||
| 1516 | |||
| 1517 | The L</count_percolate()> request works just like the L</percolate()> | ||
| 1518 | request except that it returns a count of all matching queries, instead | ||
| 1519 | of the queries themselves. | ||
| 1520 | |||
| 1521 | $results = $e->count_percolate( | ||
| 1522 | index => 'my_index', | ||
| 1523 | type => 'my_type', | ||
| 1524 | body => { | ||
| 1525 | doc => { | ||
| 1526 | title => 'Elasticsearch rocks' | ||
| 1527 | } | ||
| 1528 | } | ||
| 1529 | ); | ||
| 1530 | |||
| 1531 | Query string parameters: | ||
| 1532 | C<allow_no_indices>, | ||
| 1533 | C<error_trace>, | ||
| 1534 | C<expand_wildcards>, | ||
| 1535 | C<human>, | ||
| 1536 | C<ignore_unavailable>, | ||
| 1537 | C<percolate_index>, | ||
| 1538 | C<percolate_type>, | ||
| 1539 | C<preference>, | ||
| 1540 | C<routing>, | ||
| 1541 | C<version>, | ||
| 1542 | C<version_type> | ||
| 1543 | |||
| 1544 | See the L<percolate docs|http://www.elastic.co/guide/en/elasticsearch/reference/current/search-percolate.html> | ||
| 1545 | for more information. | ||
| 1546 | |||
| 1547 | =head2 C<mpercolate()> | ||
| 1548 | |||
| 1549 | $results = $e->mpercolate( | ||
| 1550 | index => 'my_index', # required if type | ||
| 1551 | type => 'my_type', # optional | ||
| 1552 | |||
| 1553 | body => [ percolation requests ] # required | ||
| 1554 | ); | ||
| 1555 | |||
| 1556 | Multi-percolation allows multiple L</percolate()> requests to be run | ||
| 1557 | in a single request. | ||
| 1558 | |||
| 1559 | $results = $e->mpercolate( | ||
| 1560 | index => 'my_index', | ||
| 1561 | type => 'my_type', | ||
| 1562 | body => [ | ||
| 1563 | # first request | ||
| 1564 | { percolate => { | ||
| 1565 | index => 'twitter', | ||
| 1566 | type => 'tweet' | ||
| 1567 | }}, | ||
| 1568 | { doc => {message => 'some_text' }}, | ||
| 1569 | |||
| 1570 | # second request | ||
| 1571 | { percolate => { | ||
| 1572 | index => 'twitter', | ||
| 1573 | type => 'tweet', | ||
| 1574 | id => 1 | ||
| 1575 | }}, | ||
| 1576 | {}, | ||
| 1577 | ] | ||
| 1578 | ); | ||
| 1579 | |||
| 1580 | Query string parameters: | ||
| 1581 | C<allow_no_indices>, | ||
| 1582 | C<error_trace>, | ||
| 1583 | C<expand_wildcards>, | ||
| 1584 | C<human>, | ||
| 1585 | C<ignore_unavailable> | ||
| 1586 | |||
| 1587 | See the L<mpercolate docs|http://www.elastic.co/guide/en/elasticsearch/reference/current/search-percolate.html> | ||
| 1588 | for more information. | ||
| 1589 | |||
| 1590 | =head2 C<suggest()> | ||
| 1591 | |||
| 1592 | $results = $e->suggest( | ||
| 1593 | index => 'index' | \@indices, # optional | ||
| 1594 | |||
| 1595 | body => { suggest request } # required | ||
| 1596 | ); | ||
| 1597 | |||
| 1598 | The C<suggest()> method is used to run | ||
| 1599 | L<did-you-mean|http://www.elastic.co/guide/en/elasticsearch/reference/current/search-suggesteres-phrase.html> | ||
| 1600 | or L<search-as-you-type|http://www.elastic.co/guide/en/elasticsearch/reference/current/search-suggesters-completion.html> | ||
| 1601 | suggestion requests, which can also be run as part of a L</search()> request. | ||
| 1602 | |||
| 1603 | $results = $e->suggest( | ||
| 1604 | index => 'my_index', | ||
| 1605 | body => { | ||
| 1606 | my_suggestions => { | ||
| 1607 | phrase => { | ||
| 1608 | text => 'johnny walker', | ||
| 1609 | field => 'title' | ||
| 1610 | } | ||
| 1611 | } | ||
| 1612 | } | ||
| 1613 | ); | ||
| 1614 | |||
| 1615 | Query string parameters: | ||
| 1616 | C<allow_no_indices>, | ||
| 1617 | C<error_trace>, | ||
| 1618 | C<expand_wildcards>, | ||
| 1619 | C<human>, | ||
| 1620 | C<ignore_unavailable>, | ||
| 1621 | C<preference>, | ||
| 1622 | C<routing> | ||
| 1623 | |||
| 1624 | =head1 INDEXED SCRIPT METHODS | ||
| 1625 | |||
| 1626 | Elasticsearch allows you to store scripts in the cluster state | ||
| 1627 | and reference them by id. The methods to manage indexed scripts are as follows: | ||
| 1628 | |||
| 1629 | =head2 C<put_script()> | ||
| 1630 | |||
| 1631 | $result = $e->put_script( | ||
| 1632 | lang => 'lang', # required | ||
| 1633 | id => 'id', # required | ||
| 1634 | body => { script } # required | ||
| 1635 | ); | ||
| 1636 | |||
| 1637 | The C<put_script()> method is used to store a script in the cluster state. For instance: | ||
| 1638 | |||
| 1639 | $result = $e->put_scripts( | ||
| 1640 | lang => 'painless', | ||
| 1641 | id => 'hello_world', | ||
| 1642 | body => { | ||
| 1643 | script => { | ||
| 1644 | lang => 'painless', | ||
| 1645 | source => q(return "hello world") | ||
| 1646 | } | ||
| 1647 | } | ||
| 1648 | ); | ||
| 1649 | |||
| 1650 | Query string parameters: | ||
| 1651 | C<error_trace>, | ||
| 1652 | C<human>, | ||
| 1653 | C<master_timeout>, | ||
| 1654 | C<timeout> | ||
| 1655 | |||
| 1656 | See the L<indexed scripts docs|http://www.elastic.co/guide/en/elasticsearch/reference/current/modules-scripting.html#_indexed_scripts> for more. | ||
| 1657 | |||
| 1658 | =head2 C<get_script()> | ||
| 1659 | |||
| 1660 | $script = $e->get_script( | ||
| 1661 | lang => 'lang', # required | ||
| 1662 | id => 'id', # required | ||
| 1663 | ); | ||
| 1664 | |||
| 1665 | Retrieve the indexed script from the cluster state. | ||
| 1666 | |||
| 1667 | Query string parameters: | ||
| 1668 | C<error_trace>, | ||
| 1669 | C<human> | ||
| 1670 | |||
| 1671 | See the L<indexed scripts docs|http://www.elastic.co/guide/en/elasticsearch/reference/current/modules-scripting.html#_indexed_scripts> for more. | ||
| 1672 | |||
| 1673 | =head2 C<delete_script()> | ||
| 1674 | |||
| 1675 | $script = $e->delete_script( | ||
| 1676 | lang => 'lang', # required | ||
| 1677 | id => 'id', # required | ||
| 1678 | ); | ||
| 1679 | |||
| 1680 | Delete the indexed script from the cluster state. | ||
| 1681 | |||
| 1682 | Query string parameters: | ||
| 1683 | C<error_trace>, | ||
| 1684 | C<human>, | ||
| 1685 | C<master_timeout>, | ||
| 1686 | C<timeout> | ||
| 1687 | |||
| 1688 | See the L<indexed scripts docs|http://www.elastic.co/guide/en/elasticsearch/reference/current/modules-scripting.html#_indexed_scripts> for more. | ||
| 1689 | |||
| 1690 | =head1 INDEXED SEARCH TEMPLATE METHODS | ||
| 1691 | |||
| 1692 | Mustache templates can be used to create search requests. These templates can | ||
| 1693 | be stored in the cluster state and retrieved by ID. The methods to | ||
| 1694 | manage indexed scripts are as follows: | ||
| 1695 | |||
| 1696 | =head2 C<put_template()> | ||
| 1697 | |||
| 1698 | $result = $e->put_template( | ||
| 1699 | id => 'id', # required | ||
| 1700 | body => { template } || "template" # required | ||
| 1701 | ); | ||
| 1702 | |||
| 1703 | The C<put_template()> method is used to store a template in the cluster state. | ||
| 1704 | For instance: | ||
| 1705 | |||
| 1706 | $result = $e->put_template( | ||
| 1707 | id => 'hello_world', | ||
| 1708 | body => { | ||
| 1709 | template => { | ||
| 1710 | query => { | ||
| 1711 | match => { | ||
| 1712 | title => "hello world" | ||
| 1713 | } | ||
| 1714 | } | ||
| 1715 | } | ||
| 1716 | } | ||
| 1717 | ); | ||
| 1718 | |||
| 1719 | Query string parameters: | ||
| 1720 | C<error_trace>, | ||
| 1721 | C<human> | ||
| 1722 | |||
| 1723 | See the L<indexed search template docs|http://www.elastic.co/guide/en/elasticsearch/reference/current/search-template.html#_pre_registered_template> for more. | ||
| 1724 | |||
| 1725 | =head2 C<get_template()> | ||
| 1726 | |||
| 1727 | $script = $e->get_template( | ||
| 1728 | id => 'id', # required | ||
| 1729 | ); | ||
| 1730 | |||
| 1731 | Retrieve the indexed template from the cluster state. | ||
| 1732 | |||
| 1733 | Query string parameters: | ||
| 1734 | C<error_trace>, | ||
| 1735 | C<human> | ||
| 1736 | |||
| 1737 | See the L<indexed search template docs|http://www.elastic.co/guide/en/elasticsearch/reference/current/search-template.html#_pre_registered_template> for more. | ||
| 1738 | |||
| 1739 | =head2 C<delete_template()> | ||
| 1740 | |||
| 1741 | $script = $e->delete_template( | ||
| 1742 | id => 'id', # required | ||
| 1743 | ); | ||
| 1744 | |||
| 1745 | Delete the indexed template from the cluster state. | ||
| 1746 | |||
| 1747 | Query string parameters: | ||
| 1748 | C<error_trace>, | ||
| 1749 | C<human> | ||
| 1750 | |||
| 1751 | See the L<indexed search template docs|http://www.elastic.co/guide/en/elasticsearch/reference/current/search-template.html#_pre_registered_template> for more. | ||
| 1752 | |||
| 1753 | =head1 AUTHOR | ||
| 1754 | |||
| 1755 | Enrico Zimuel <enrico.zimuel@elastic.co> | ||
| 1756 | |||
| 1757 | =head1 COPYRIGHT AND LICENSE | ||
| 1758 | |||
| 1759 | This software is Copyright (c) 2020 by Elasticsearch BV. | ||
| 1760 | |||
| 1761 | This is free software, licensed under: | ||
| 1762 | |||
| 1763 | The Apache License, Version 2.0, January 2004 | ||
| 1764 | |||
| 1765 | =cut | ||
| 1766 | |||
| 1767 | __END__ |