.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.40) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "Search::Elasticsearch::Client::1_0::Direct 3pm" .TH Search::Elasticsearch::Client::1_0::Direct 3pm "2020-11-25" "perl v5.32.0" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" Search::Elasticsearch::Client::1_0::Direct \- Thin client with full support for Elasticsearch 1.x APIs .SH "VERSION" .IX Header "VERSION" version 6.81 .SH "SYNOPSIS" .IX Header "SYNOPSIS" Create a client: .PP .Vb 4 \& use Search::Elasticsearch; \& my $e = Search::Elasticsearch\->new( \& client => \*(Aq1_0::Direct\*(Aq \& ); .Ve .PP Index a doc: .PP .Vb 10 \& $e\->index( \& index => \*(Aqmy_index\*(Aq, \& type => \*(Aqblog_post\*(Aq, \& id => 123, \& body => { \& title => "Elasticsearch clients", \& content => "Interesting content...", \& date => "2013\-09\-23" \& } \& ); .Ve .PP Get a doc: .PP .Vb 5 \& $e\->get( \& index => \*(Aqmy_index\*(Aq, \& type => \*(Aqmy_type\*(Aq, \& id => 123 \& ); .Ve .PP Search for docs: .PP .Vb 10 \& $results = $e\->search( \& index => \*(Aqmy_index\*(Aq, \& body => { \& query => { \& match => { \& title => "elasticsearch" \& } \& } \& } \& ); .Ve .PP Index-level requests: .PP .Vb 2 \& $e\->indices\->create( index => \*(Aqmy_index\*(Aq ); \& $e\->indices\->delete( index => \*(Aqmy_index\*(Aq ) .Ve .PP Cluster-level requests: .PP .Vb 1 \& $health = $e\->cluster\->health; .Ve .PP Node-level requests: .PP .Vb 2 \& $info = $e\->nodes\->info; \& $stats = $e\->nodes\->stats; .Ve .PP Snapshot and restore: .PP .Vb 7 \& $e\->snapshot\->create_repository( \& repository => \*(Aqmy_backups\*(Aq, \& type => \*(Aqfs\*(Aq, \& settings => { \& location => \*(Aq/mnt/backups\*(Aq \& } \& ); \& \& $e\->snapshot\->create( \& repository => \*(Aqmy_backups\*(Aq, \& snapshot => \*(Aqbackup_2014\*(Aq \& ); .Ve .PP `cat` debugging: .PP .Vb 2 \& say $e\->cat\->allocation; \& say $e\->cat\->health; .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" The Search::Elasticsearch::Client::1_0::Direct class provides the Elasticsearch 1.x compatible client that is returned by: .PP .Vb 1 \& $e = Search::Elasticsearch\->new( cxn => \*(Aq1_0::Direct\*(Aq ); .Ve .PP It is intended to be as close as possible to the native \s-1REST API\s0 that Elasticsearch uses, so that it is easy to translate the Elasticsearch reference documentation for an \s-1API\s0 to the equivalent in this client. .PP This class provides the methods for document \s-1CRUD\s0, bulk document \s-1CRUD\s0 and search. It also provides access to clients for managing indices and the cluster. .SH "CONVENTIONS" .IX Header "CONVENTIONS" .SS "Parameter passing" .IX Subsection "Parameter passing" Parameters can be passed to any request method as a list or as a hash reference. The following two statements are equivalent: .PP .Vb 2 \& $e\->search( size => 10 ); \& $e\->search({size => 10}); .Ve .SS "Path parameters" .IX Subsection "Path parameters" Any values that should be included in the \s-1URL\s0 path, eg \f(CW\*(C`/{index}/{type}\*(C'\fR should be passed as top level parameters: .PP .Vb 1 \& $e\->search( index => \*(Aqmy_index\*(Aq, type => \*(Aqmy_type\*(Aq ); .Ve .PP Alternatively, you can specify a \f(CW\*(C`path\*(C'\fR parameter directly: .PP .Vb 1 \& $e\->search( path => \*(Aq/my_index/my_type\*(Aq ); .Ve .SS "Query-string parameters" .IX Subsection "Query-string parameters" Any values that should be included in the query string should be passed as top level parameters: .PP .Vb 1 \& $e\->search( size => 10 ); .Ve .PP If you pass in a \f(CW\*(C`\e%params\*(C'\fR hash, then it will be included in the query string parameters without any error checking. The following: .PP .Vb 1 \& $e\->search( size => 10, params => { from => 5, size => 5 }) .Ve .PP would result in this query string: .PP .Vb 1 \& ?from=5&size=10 .Ve .SS "Body parameter" .IX Subsection "Body parameter" The request body should be passed in the \f(CW\*(C`body\*(C'\fR key: .PP .Vb 5 \& $e\->search( \& body => { \& query => {...} \& } \& ); .Ve .PP The body can also be a UTF8\-decoded string, which will be converted into \&\s-1UTF\-8\s0 bytes and passed as is: .PP .Vb 1 \& $e\->indices\->analyze( body => "The quick brown fox"); .Ve .SS "Filter path parameter" .IX Subsection "Filter path parameter" Any \s-1API\s0 which returns a \s-1JSON\s0 body accepts a \f(CW\*(C`filter_path\*(C'\fR parameter which will filter the \s-1JSON\s0 down to only the specified paths. For instance, if you are running a search request and only want the \f(CW\*(C`total\*(C'\fR hits and the \f(CW\*(C`_source\*(C'\fR field for each hit (without the \f(CW\*(C`_id\*(C'\fR, \f(CW\*(C`_index\*(C'\fR etc), you can do: .PP .Vb 4 \& $e\->search( \& query => {...}, \& filter_path => [ \*(Aqhits.total\*(Aq, \*(Aqhits.hits._source\*(Aq ] \& ); .Ve .PP This parameter was added in Elasticsearch 1.6.0. .SS "Ignore parameter" .IX Subsection "Ignore parameter" Normally, any \s-1HTTP\s0 status code outside the 200\-299 range will result in an error being thrown. To suppress these errors, you can specify which status codes to ignore in the \f(CW\*(C`ignore\*(C'\fR parameter. .PP .Vb 4 \& $e\->indices\->delete( \& index => \*(Aqmy_index\*(Aq, \& ignore => 404 \& ); .Ve .PP This is most useful for Missing errors, which are triggered by a \f(CW404\fR status code when some requested resource does not exist. .PP Multiple error codes can be specified with an array: .PP .Vb 4 \& $e\->indices\->delete( \& index => \*(Aqmy_index\*(Aq, \& ignore => [404,409] \& ); .Ve .SH "CONFIGURATION" .IX Header "CONFIGURATION" .ie n .SS """bulk_helper_class""" .el .SS "\f(CWbulk_helper_class\fP" .IX Subsection "bulk_helper_class" The class to use for the \*(L"\fBbulk_helper()\fR\*(R" method. Defaults to Search::Elasticsearch::Client::1_0::Bulk. .ie n .SS """scroll_helper_class""" .el .SS "\f(CWscroll_helper_class\fP" .IX Subsection "scroll_helper_class" The class to use for the \*(L"\fBscroll_helper()\fR\*(R" method. Defaults to Search::Elasticsearch::Scroll. .SH "GENERAL METHODS" .IX Header "GENERAL METHODS" .ie n .SS """info()""" .el .SS "\f(CWinfo()\fP" .IX Subsection "info()" .Vb 1 \& $info = $e\->info .Ve .PP Returns information about the version of Elasticsearch that the responding node is running. .ie n .SS """ping()""" .el .SS "\f(CWping()\fP" .IX Subsection "ping()" .Vb 1 \& $e\->ping .Ve .PP Pings a node in the cluster and returns \f(CW1\fR if it receives a \f(CW200\fR response, otherwise it throws an error. .ie n .SS """indices()""" .el .SS "\f(CWindices()\fP" .IX Subsection "indices()" .Vb 1 \& $indices_client = $e\->indices; .Ve .PP Returns an Search::Elasticsearch::Client::1_0::Direct::Indices object which can be used for managing indices, eg creating, deleting indices, managing mapping, index settings etc. .ie n .SS """cluster()""" .el .SS "\f(CWcluster()\fP" .IX Subsection "cluster()" .Vb 1 \& $cluster_client = $e\->cluster; .Ve .PP Returns an Search::Elasticsearch::Client::1_0::Direct::Cluster object which can be used for managing the cluster, eg cluster-wide settings and cluster health. .ie n .SS """nodes()""" .el .SS "\f(CWnodes()\fP" .IX Subsection "nodes()" .Vb 1 \& $node_client = $e\->nodes; .Ve .PP Returns an Search::Elasticsearch::Client::1_0::Direct::Nodes object which can be used to retrieve node info and stats. .ie n .SS """snapshot()""" .el .SS "\f(CWsnapshot()\fP" .IX Subsection "snapshot()" .Vb 1 \& $snapshot_client = $e\->snapshot; .Ve .PP Returns an Search::Elasticsearch::Client::1_0::Direct::Snapshot object which is used for managing backup repositories and creating and restoring snapshots. .ie n .SS """cat()""" .el .SS "\f(CWcat()\fP" .IX Subsection "cat()" .Vb 1 \& $cat_client = $e\->cat; .Ve .PP Returns an Search::Elasticsearch::Client::1_0::Direct::Cat object which can be used to retrieve simple to read text info for debugging and monitoring an Elasticsearch cluster. .SH "DOCUMENT CRUD METHODS" .IX Header "DOCUMENT CRUD METHODS" These methods allow you to perform create, index, update and delete requests for single documents: .ie n .SS """index()""" .el .SS "\f(CWindex()\fP" .IX Subsection "index()" .Vb 4 \& $response = $e\->index( \& index => \*(Aqindex_name\*(Aq, # required \& type => \*(Aqtype_name\*(Aq, # required \& id => \*(Aqdoc_id\*(Aq, # optional, otherwise auto\-generated \& \& body => { document } # required \& ); .Ve .PP The \f(CW\*(C`index()\*(C'\fR method is used to index a new document or to reindex an existing document. .PP Query string parameters: \f(CW\*(C`consistency\*(C'\fR, \f(CW\*(C`op_type\*(C'\fR, \f(CW\*(C`parent\*(C'\fR, \f(CW\*(C`refresh\*(C'\fR, \f(CW\*(C`replication\*(C'\fR, \f(CW\*(C`routing\*(C'\fR, \f(CW\*(C`timeout\*(C'\fR, \f(CW\*(C`timestamp\*(C'\fR, \f(CW\*(C`ttl\*(C'\fR, \f(CW\*(C`version\*(C'\fR, \f(CW\*(C`version_type\*(C'\fR .PP See the index docs for more information. .ie n .SS """create()""" .el .SS "\f(CWcreate()\fP" .IX Subsection "create()" .Vb 4 \& $response = $e\->create( \& index => \*(Aqindex_name\*(Aq, # required \& type => \*(Aqtype_name\*(Aq, # required \& id => \*(Aqdoc_id\*(Aq, # optional, otherwise auto\-generated \& \& body => { document } # required \& ); .Ve .PP The \f(CW\*(C`create()\*(C'\fR method works exactly like the \*(L"\fBindex()\fR\*(R" method, except that it will throw a \f(CW\*(C`Conflict\*(C'\fR error if a document with the same \&\f(CW\*(C`index\*(C'\fR, \f(CW\*(C`type\*(C'\fR and \f(CW\*(C`id\*(C'\fR already exists. .PP Query string parameters: \f(CW\*(C`consistency\*(C'\fR, \f(CW\*(C`op_type\*(C'\fR, \f(CW\*(C`parent\*(C'\fR, \f(CW\*(C`refresh\*(C'\fR, \f(CW\*(C`replication\*(C'\fR, \f(CW\*(C`routing\*(C'\fR, \f(CW\*(C`timeout\*(C'\fR, \f(CW\*(C`timestamp\*(C'\fR, \f(CW\*(C`ttl\*(C'\fR, \f(CW\*(C`version\*(C'\fR, \f(CW\*(C`version_type\*(C'\fR .PP See the create docs for more information. .ie n .SS """get()""" .el .SS "\f(CWget()\fP" .IX Subsection "get()" .Vb 5 \& $response = $e\->get( \& index => \*(Aqindex_name\*(Aq, # required \& type => \*(Aqtype_name\*(Aq, # required \& id => \*(Aqdoc_id\*(Aq, # required \& ); .Ve .PP The \f(CW\*(C`get()\*(C'\fR method will retrieve the document with the specified \&\f(CW\*(C`index\*(C'\fR, \f(CW\*(C`type\*(C'\fR and \f(CW\*(C`id\*(C'\fR, or will throw a \f(CW\*(C`Missing\*(C'\fR error. .PP Query string parameters: \f(CW\*(C`_source\*(C'\fR, \f(CW\*(C`_source_exclude\*(C'\fR, \f(CW\*(C`_source_include\*(C'\fR, \f(CW\*(C`fields\*(C'\fR, \f(CW\*(C`parent\*(C'\fR, \f(CW\*(C`preference\*(C'\fR, \f(CW\*(C`realtime\*(C'\fR, \f(CW\*(C`refresh\*(C'\fR, \f(CW\*(C`routing\*(C'\fR, \f(CW\*(C`version\*(C'\fR, \f(CW\*(C`version_type\*(C'\fR .PP See the get docs for more information. .ie n .SS """get_source()""" .el .SS "\f(CWget_source()\fP" .IX Subsection "get_source()" .Vb 5 \& $response = $e\->get_source( \& index => \*(Aqindex_name\*(Aq, # required \& type => \*(Aqtype_name\*(Aq, # required \& id => \*(Aqdoc_id\*(Aq, # required \& ); .Ve .PP The \f(CW\*(C`get_source()\*(C'\fR method works just like the \*(L"\fBget()\fR\*(R" method except that it returns just the \f(CW\*(C`_source\*(C'\fR field (the value of the \f(CW\*(C`body\*(C'\fR parameter in the \*(L"\fBindex()\fR\*(R" method) instead of returning the \f(CW\*(C`_source\*(C'\fR field plus the document metadata, ie the \f(CW\*(C`_index\*(C'\fR, \f(CW\*(C`_type\*(C'\fR etc. .PP Query string parameters: \f(CW\*(C`_source\*(C'\fR, \f(CW\*(C`_source_exclude\*(C'\fR, \f(CW\*(C`_source_include\*(C'\fR, \f(CW\*(C`parent\*(C'\fR, \f(CW\*(C`preference\*(C'\fR, \f(CW\*(C`realtime\*(C'\fR, \f(CW\*(C`refresh\*(C'\fR, \f(CW\*(C`routing\*(C'\fR, \f(CW\*(C`version\*(C'\fR, \f(CW\*(C`version_type\*(C'\fR .PP See the get_source docs for more information. .ie n .SS """exists()""" .el .SS "\f(CWexists()\fP" .IX Subsection "exists()" .Vb 5 \& $response = $e\->exists( \& index => \*(Aqindex_name\*(Aq, # required \& type => \*(Aqtype_name\*(Aq, # required \& id => \*(Aqdoc_id\*(Aq, # required \& ); .Ve .PP The \f(CW\*(C`exists()\*(C'\fR method returns \f(CW1\fR if a document with the specified \&\f(CW\*(C`index\*(C'\fR, \f(CW\*(C`type\*(C'\fR and \f(CW\*(C`id\*(C'\fR exists, or an empty string if it doesn't. .PP Query string parameters: \f(CW\*(C`parent\*(C'\fR, \f(CW\*(C`preference\*(C'\fR, \f(CW\*(C`realtime\*(C'\fR, \f(CW\*(C`refresh\*(C'\fR, \f(CW\*(C`routing\*(C'\fR .PP See the exists docs for more information. .ie n .SS """delete()""" .el .SS "\f(CWdelete()\fP" .IX Subsection "delete()" .Vb 5 \& $response = $e\->delete( \& index => \*(Aqindex_name\*(Aq, # required \& type => \*(Aqtype_name\*(Aq, # required \& id => \*(Aqdoc_id\*(Aq, # required \& ); .Ve .PP The \f(CW\*(C`delete()\*(C'\fR method will delete the document with the specified \&\f(CW\*(C`index\*(C'\fR, \f(CW\*(C`type\*(C'\fR and \f(CW\*(C`id\*(C'\fR, or will throw a \f(CW\*(C`Missing\*(C'\fR error. .PP Query string parameters: \f(CW\*(C`consistency\*(C'\fR, \f(CW\*(C`parent\*(C'\fR, \f(CW\*(C`refresh\*(C'\fR, \f(CW\*(C`replication\*(C'\fR, \f(CW\*(C`routing\*(C'\fR, \f(CW\*(C`timeout\*(C'\fR, \f(CW\*(C`version\*(C'\fR, \f(CW\*(C`version_type\*(C'\fR .PP See the delete docs for more information. .ie n .SS """update()""" .el .SS "\f(CWupdate()\fP" .IX Subsection "update()" .Vb 4 \& $response = $e\->update( \& index => \*(Aqindex_name\*(Aq, # required \& type => \*(Aqtype_name\*(Aq, # required \& id => \*(Aqdoc_id\*(Aq, # required \& \& body => { update } # required \& ); .Ve .PP The \f(CW\*(C`update()\*(C'\fR method updates a document with the corresponding \&\f(CW\*(C`index\*(C'\fR, \f(CW\*(C`type\*(C'\fR and \f(CW\*(C`id\*(C'\fR if it exists. Updates can be performed either by: .IP "\(bu" 4 providing a partial document to be merged in to the existing document: .Sp .Vb 6 \& $response = $e\->update( \& ..., \& body => { \& doc => { new_field => \*(Aqnew_value\*(Aq}, \& } \& ); .Ve .IP "\(bu" 4 or with a script: .Sp .Vb 7 \& $response = $e\->update( \& ..., \& body => { \& script => "ctx._source.counter += incr", \& params => { incr => 5 } \& } \& ); .Ve .PP Query string parameters: \f(CW\*(C`consistency\*(C'\fR, \f(CW\*(C`fields\*(C'\fR, \f(CW\*(C`lang\*(C'\fR, \f(CW\*(C`parent\*(C'\fR, \f(CW\*(C`realtime\*(C'\fR, \f(CW\*(C`refresh\*(C'\fR, \f(CW\*(C`replication\*(C'\fR, \f(CW\*(C`retry_on_conflict\*(C'\fR, \f(CW\*(C`routing\*(C'\fR, \f(CW\*(C`script\*(C'\fR, \f(CW\*(C`script_id\*(C'\fR, \f(CW\*(C`scripted_upsert\*(C'\fR, \f(CW\*(C`timeout\*(C'\fR, \f(CW\*(C`timestamp\*(C'\fR, \f(CW\*(C`ttl\*(C'\fR, \f(CW\*(C`version\*(C'\fR, \f(CW\*(C`version_type\*(C'\fR .PP See the update docs for more information. .ie n .SS """termvectors()""" .el .SS "\f(CWtermvectors()\fP" .IX Subsection "termvectors()" .Vb 3 \& $results = $e\->termvectors( \& index => $index, # required \& type => $type, # required \& \& id => $id, # optional \& body => {...} # optional \& ) .Ve .PP The \f(CW\*(C`termvectors()\*(C'\fR method retrieves term and field statistics, positions, offsets and payloads for the specified document, assuming that termvectors have been enabled. .PP Query string parameters: \f(CW\*(C`dfs\*(C'\fR, \f(CW\*(C`field_statistics\*(C'\fR, \f(CW\*(C`fields\*(C'\fR, \f(CW\*(C`offsets\*(C'\fR, \f(CW\*(C`parent\*(C'\fR, \f(CW\*(C`payloads\*(C'\fR, \f(CW\*(C`positions\*(C'\fR, \f(CW\*(C`preference\*(C'\fR, \f(CW\*(C`realtime\*(C'\fR, \f(CW\*(C`routing\*(C'\fR, \f(CW\*(C`term_statistics\*(C'\fR, \f(CW\*(C`version\*(C'\fR, \f(CW\*(C`version_type\*(C'\fR .PP See the termvector docs for more information. .SH "BULK DOCUMENT CRUD METHODS" .IX Header "BULK DOCUMENT CRUD METHODS" The bulk document \s-1CRUD\s0 methods are used for running multiple \s-1CRUD\s0 actions within a single request. By reducing the number of network requests that need to be made, bulk requests greatly improve performance. .ie n .SS """bulk()""" .el .SS "\f(CWbulk()\fP" .IX Subsection "bulk()" .Vb 3 \& $response = $e\->bulk( \& index => \*(Aqindex_name\*(Aq, # required if type specified \& type => \*(Aqtype_name\*(Aq, # optional \& \& body => [ actions ] # required \& ); .Ve .PP See Search::Elasticsearch::Client::1_0::Bulk and \*(L"\fBbulk_helper()\fR\*(R" for a helper module that makes bulk indexing simpler to use. .PP The \f(CW\*(C`bulk()\*(C'\fR method can perform multiple \*(L"\fBindex()\fR\*(R", \*(L"\fBcreate()\fR\*(R", \&\*(L"\fBdelete()\fR\*(R" or \*(L"\fBupdate()\fR\*(R" actions with a single request. The \f(CW\*(C`body\*(C'\fR parameter expects an array containing the list of actions to perform. .PP An \fIaction\fR consists of an initial metadata hash ref containing the action type, plus the associated metadata, eg : .PP .Vb 1 \& { delete => { _index => \*(Aqindex\*(Aq, _type => \*(Aqtype\*(Aq, _id => 123 }} .Ve .PP The \f(CW\*(C`index\*(C'\fR and \f(CW\*(C`create\*(C'\fR actions then expect a hashref containing the document itself: .PP .Vb 2 \& { create => { _index => \*(Aqindex\*(Aq, _type => \*(Aqtype\*(Aq, _id => 123 }}, \& { title => "A newly created document" } .Ve .PP And the \f(CW\*(C`update\*(C'\fR action expects a hashref containing the update commands, eg: .PP .Vb 2 \& { update => { _index => \*(Aqindex\*(Aq, _type => \*(Aqtype\*(Aq, _id => 123 }}, \& { script => "ctx._source.counter+=1" } .Ve .PP Each action can include the same parameters that you would pass to the equivalent \*(L"\fBindex()\fR\*(R", \*(L"\fBcreate()\fR\*(R", \*(L"\fBdelete()\fR\*(R" or \*(L"\fBupdate()\fR\*(R" request, except that \f(CW\*(C`_index\*(C'\fR, \f(CW\*(C`_type\*(C'\fR and \f(CW\*(C`_id\*(C'\fR must be specified with the preceding underscore. All other parameters can be specified with or without the underscore. .PP For instance: .PP .Vb 4 \& $response = $e\->bulk( \& index => \*(Aqindex_name\*(Aq, # default index name \& type => \*(Aqtype_name\*(Aq, # default type name \& body => [ \& \& # create action \& { create => { \& _index => \*(Aqnot_the_default_index\*(Aq, \& _type => \*(Aqnot_the_default_type\*(Aq, \& _id => 123 \& }}, \& { title => \*(AqFoo\*(Aq }, \& \& # index action \& { index => { _id => 124 }}, \& { title => \*(AqFoo\*(Aq }, \& \& # delete action \& { delete => { _id => 125 }}, \& \& # update action \& { update => { _id => 126 }}, \& { script => "ctx._source.counter+1" } \& ] \& ); .Ve .PP Each action is performed separately. One failed action will not cause the others to fail as well. .PP Query string parameters: \f(CW\*(C`consistency\*(C'\fR, \f(CW\*(C`refresh\*(C'\fR, \f(CW\*(C`replication\*(C'\fR, \f(CW\*(C`timeout\*(C'\fR .PP See the bulk docs for more information. .ie n .SS """bulk_helper()""" .el .SS "\f(CWbulk_helper()\fP" .IX Subsection "bulk_helper()" .Vb 1 \& $bulk_helper = $e\->bulk_helper( @args ); .Ve .PP Returns a new instance of the class specified in the \*(L"bulk_helper_class\*(R", which defaults to Search::Elasticsearch::Client::1_0::Bulk. .ie n .SS """mget()""" .el .SS "\f(CWmget()\fP" .IX Subsection "mget()" .Vb 3 \& $results = $e\->mget( \& index => \*(Aqdefault_index\*(Aq, # optional, required when type specified \& type => \*(Aqdefault_type\*(Aq, # optional \& \& body => { docs or ids } # required \& ); .Ve .PP The \f(CW\*(C`mget()\*(C'\fR method will retrieve multiple documents with a single request. The \f(CW\*(C`body\*(C'\fR consists of an array of documents to retrieve: .PP .Vb 10 \& $results = $e\->mget( \& index => \*(Aqdefault_index\*(Aq, \& type => \*(Aqdefault_type\*(Aq, \& body => { \& docs => [ \& { _id => 1}, \& { _id => 2, _type => \*(Aqnot_the_default_type\*(Aq } \& ] \& } \& ); .Ve .PP You can also pass any of the other parameters that the \*(L"\fBget()\fR\*(R" request accepts. .PP If you have specified an \f(CW\*(C`index\*(C'\fR and \f(CW\*(C`type\*(C'\fR, you can just include the \&\f(CW\*(C`ids\*(C'\fR of the documents to retrieve: .PP .Vb 7 \& $results = $e\->mget( \& index => \*(Aqdefault_index\*(Aq, \& type => \*(Aqdefault_type\*(Aq, \& body => { \& ids => [ 1, 2, 3] \& } \& ); .Ve .PP Query string parameters: \f(CW\*(C`_source\*(C'\fR, \f(CW\*(C`_source_exclude\*(C'\fR, \f(CW\*(C`_source_include\*(C'\fR, \f(CW\*(C`fields\*(C'\fR, \f(CW\*(C`preference\*(C'\fR, \f(CW\*(C`realtime\*(C'\fR, \f(CW\*(C`refresh\*(C'\fR .PP See the mget docs for more information. .ie n .SS """delete_by_query()""" .el .SS "\f(CWdelete_by_query()\fP" .IX Subsection "delete_by_query()" .Vb 3 \& $result = $e\->delete_by_query( \& index => \*(Aqindex\*(Aq | \e@indices, # required \& type => \*(Aqtype\*(Aq | \e@types, # optional \& \& body => { query } # required \& \& ); .Ve .PP The \f(CW\*(C`delete_by_query()\*(C'\fR method deletes all documents which match the query. For instance, to delete all documents from 2012: .PP .Vb 12 \& $result = $e\->delete_by_query( \& body => { \& query => { \& range => { \& date => { \& gte => \*(Aq2012\-01\-01\*(Aq, \& lt => \*(Aq2013\-01\-01\*(Aq \& } \& } \& } \& } \& ); .Ve .PP Query string parameters: \f(CW\*(C`allow_no_indices\*(C'\fR, \f(CW\*(C`analyzer\*(C'\fR, \f(CW\*(C`consistency\*(C'\fR, \f(CW\*(C`default_operator\*(C'\fR, \f(CW\*(C`df\*(C'\fR, \f(CW\*(C`expand_wildcards\*(C'\fR, \f(CW\*(C`ignore_unavailable\*(C'\fR, \f(CW\*(C`q\*(C'\fR, \f(CW\*(C`replication\*(C'\fR, \f(CW\*(C`routing\*(C'\fR, \f(CW\*(C`timeout\*(C'\fR .PP See the delete_by_query docs for more information. .ie n .SS """mtermvectors()""" .el .SS "\f(CWmtermvectors()\fP" .IX Subsection "mtermvectors()" .Vb 3 \& $results = $e\->mtermvectors( \& index => $index, # required if type specified \& type => $type, # optional \& \& body => { } # optional \& ) .Ve .PP Runs multiple \*(L"\fBtermvector()\fR\*(R" requests in a single request, eg: .PP .Vb 9 \& $results = $e\->mtermvectors( \& index => \*(Aqtest\*(Aq, \& body => { \& docs => [ \& { _type => \*(Aqtest\*(Aq, _id => 1, fields => [\*(Aqtext\*(Aq] }, \& { _type => \*(Aqtest\*(Aq, _id => 2, payloads => 1 }, \& ] \& } \& ); .Ve .PP Query string parameters: \f(CW\*(C`field_statistics\*(C'\fR, \f(CW\*(C`fields\*(C'\fR, \f(CW\*(C`ids\*(C'\fR, \f(CW\*(C`offsets\*(C'\fR, \f(CW\*(C`parent\*(C'\fR, \f(CW\*(C`payloads\*(C'\fR, \f(CW\*(C`positions\*(C'\fR, \f(CW\*(C`preference\*(C'\fR, \f(CW\*(C`realtime\*(C'\fR, \f(CW\*(C`routing\*(C'\fR, \f(CW\*(C`term_statistics\*(C'\fR, \f(CW\*(C`version\*(C'\fR, \f(CW\*(C`version_type\*(C'\fR .PP See the mtermvectors docs for more information. .SH "SEARCH METHODS" .IX Header "SEARCH METHODS" The search methods are used for querying documents in one, more or all indices and of one, more or all types: .ie n .SS """search()""" .el .SS "\f(CWsearch()\fP" .IX Subsection "search()" .Vb 3 \& $results = $e\->search( \& index => \*(Aqindex\*(Aq | \e@indices, # optional \& type => \*(Aqtype\*(Aq | \e@types, # optional \& \& body => { search params } # optional \& ); .Ve .PP The \f(CW\*(C`search()\*(C'\fR method searches for matching documents in one or more indices. It is just as easy to search a single index as it is to search all the indices in your cluster. It can also return aggregations highlighted snippets and did-you-mean or search-as-you-type suggestions. .PP The \fIlite\fR version of search allows you to specify a query string in the \f(CW\*(C`q\*(C'\fR parameter, using the Lucene query string syntax: .PP .Vb 1 \& $results = $e\->search( q => \*(Aqtitle:(elasticsearch clients)\*(Aq); .Ve .PP However, the preferred way to search is by using the Query \s-1DSL\s0 to create a query, and passing that \f(CW\*(C`query\*(C'\fR in the request body : .PP .Vb 7 \& $results = $e\->search( \& body => { \& query => { \& match => { title => \*(AqElasticsearch clients\*(Aq} \& } \& } \& ); .Ve .PP Query string parameters: \f(CW\*(C`_source\*(C'\fR, \f(CW\*(C`_source_exclude\*(C'\fR, \f(CW\*(C`_source_include\*(C'\fR, \f(CW\*(C`allow_no_indices\*(C'\fR, \f(CW\*(C`analyze_wildcard\*(C'\fR, \f(CW\*(C`analyzer\*(C'\fR, \f(CW\*(C`default_operator\*(C'\fR, \f(CW\*(C`df\*(C'\fR, \f(CW\*(C`expand_wildcards\*(C'\fR, \f(CW\*(C`explain\*(C'\fR, \f(CW\*(C`fielddata_fields\*(C'\fR, \f(CW\*(C`fields\*(C'\fR, \f(CW\*(C`from\*(C'\fR, \f(CW\*(C`ignore_unavailable\*(C'\fR, \f(CW\*(C`lenient\*(C'\fR, \f(CW\*(C`lowercase_expanded_terms\*(C'\fR, \f(CW\*(C`preference\*(C'\fR, \f(CW\*(C`q\*(C'\fR, \f(CW\*(C`query_cache\*(C'\fR, \f(CW\*(C`routing\*(C'\fR, \f(CW\*(C`scroll\*(C'\fR, \f(CW\*(C`search_type\*(C'\fR, \f(CW\*(C`size\*(C'\fR, \f(CW\*(C`sort\*(C'\fR, \f(CW\*(C`stats\*(C'\fR, \f(CW\*(C`suggest_field\*(C'\fR, \f(CW\*(C`suggest_mode\*(C'\fR, \f(CW\*(C`suggest_size\*(C'\fR, \f(CW\*(C`suggest_text\*(C'\fR, \f(CW\*(C`terminate_after\*(C'\fR, \f(CW\*(C`timeout\*(C'\fR, \f(CW\*(C`track_scores\*(C'\fR, \f(CW\*(C`version\*(C'\fR .PP See the search reference for more information. .PP Also see \*(L"send_get_body_as\*(R" in Search::Elasticsearch::Transport. .ie n .SS """search_exists()""" .el .SS "\f(CWsearch_exists()\fP" .IX Subsection "search_exists()" The \f(CW\*(C`search_exists()\*(C'\fR method is a quick version of search which can be used to find out whether there are matching search results or not. It doesn't return any results itself. .PP .Vb 3 \& $results = $e\->search_exists( \& index => \*(Aqindex\*(Aq | \e@indices, # optional \& type => \*(Aqtype\*(Aq | \e@types, # optional \& \& body => { search params } # optional \& ); .Ve .PP Query string parameters: \f(CW\*(C`allow_no_indices\*(C'\fR, \f(CW\*(C`analyze_wildcard\*(C'\fR, \f(CW\*(C`analyzer\*(C'\fR, \f(CW\*(C`default_operator\*(C'\fR, \f(CW\*(C`df\*(C'\fR, \f(CW\*(C`expand_wildcards\*(C'\fR, \f(CW\*(C`ignore_unavailable\*(C'\fR, \f(CW\*(C`lenient\*(C'\fR, \f(CW\*(C`lowercase_expanded_terms\*(C'\fR, \f(CW\*(C`min_score\*(C'\fR, \f(CW\*(C`preference\*(C'\fR, \f(CW\*(C`q\*(C'\fR, \f(CW\*(C`routing\*(C'\fR .PP See the search exists reference for more information. .ie n .SS """count()""" .el .SS "\f(CWcount()\fP" .IX Subsection "count()" .Vb 3 \& $results = $e\->count( \& index => \*(Aqindex\*(Aq | \e@indices, # optional \& type => \*(Aqtype\*(Aq | \e@types, # optional \& \& body => { query } # optional \& ) .Ve .PP The \f(CW\*(C`count()\*(C'\fR method returns the total count of all documents matching the query: .PP .Vb 7 \& $results = $e\->count( \& body => { \& query => { \& match => { title => \*(AqElasticsearch clients\*(Aq } \& } \& } \& ); .Ve .PP Query string parameters: \f(CW\*(C`allow_no_indices\*(C'\fR, \f(CW\*(C`analyze_wildcard\*(C'\fR, \f(CW\*(C`analyzer\*(C'\fR, \f(CW\*(C`default_operator\*(C'\fR, \f(CW\*(C`df\*(C'\fR, \f(CW\*(C`expand_wildcards\*(C'\fR, \f(CW\*(C`ignore_unavailable\*(C'\fR, \f(CW\*(C`lenient\*(C'\fR, \f(CW\*(C`lowercase_expanded_terms\*(C'\fR, \f(CW\*(C`min_score\*(C'\fR, \f(CW\*(C`preference\*(C'\fR, \f(CW\*(C`q\*(C'\fR, \f(CW\*(C`routing\*(C'\fR .PP See the count docs for more information. .ie n .SS """search_template()""" .el .SS "\f(CWsearch_template()\fP" .IX Subsection "search_template()" .Vb 3 \& $results = $e\->search_template( \& index => \*(Aqindex\*(Aq | \e@indices, # optional \& type => \*(Aqtype\*(Aq | \e@types, # optional \& \& body => { search params } # optional \& ); .Ve .PP Perform a search by specifying a template (either predefined or defined within the \f(CW\*(C`body\*(C'\fR) and parameters to use with the template, eg: .PP .Vb 10 \& $results = $e\->search_template( \& body => { \& template => { \& query => { \& match => { \& "{{my_field}}" => "{{my_value}}" \& } \& }, \& size => "{{my_size}}" \& }, \& params => { \& my_field => \*(Aqfoo\*(Aq, \& my_value => \*(Aqbar\*(Aq, \& my_size => 5 \& } \& } \& ); .Ve .PP See the search template docs for more information. .PP Query string parameters: \f(CW\*(C`allow_no_indices\*(C'\fR, \f(CW\*(C`expand_wildcards\*(C'\fR, \f(CW\*(C`ignore_unavailable\*(C'\fR, \f(CW\*(C`preference\*(C'\fR, \f(CW\*(C`scroll\*(C'\fR, \f(CW\*(C`search_type\*(C'\fR .ie n .SS """scroll()""" .el .SS "\f(CWscroll()\fP" .IX Subsection "scroll()" .Vb 4 \& $results = $e\->scroll( \& scroll => \*(Aq1m\*(Aq, \& scroll_id => $id \& ); .Ve .PP When a \*(L"\fBsearch()\fR\*(R" has been performed with the \&\f(CW\*(C`scroll\*(C'\fR parameter, the \f(CW\*(C`scroll()\*(C'\fR method allows you to keep pulling more results until the results are exhausted. .PP \&\fB\s-1NOTE:\s0\fR you will almost always want to set the \&\f(CW\*(C`search_type\*(C'\fR to \f(CW\*(C`scan\*(C'\fR in your original \f(CW\*(C`search()\*(C'\fR request. .PP See \*(L"\fBscroll_helper()\fR\*(R" and Search::Elasticsearch::Scroll for a helper utility which makes managing scroll requests much easier. .PP Query string parameters: \f(CW\*(C`scroll\*(C'\fR, \f(CW\*(C`scroll_id\*(C'\fR .PP See the scroll docs and the search_type docs for more information. .ie n .SS """clear_scroll()""" .el .SS "\f(CWclear_scroll()\fP" .IX Subsection "clear_scroll()" .Vb 3 \& $response = $e\->clear_scroll( \& scroll_id => $id | \e@ids # required \& ); .Ve .PP Or .PP .Vb 3 \& $response = $e\->clear_scroll( \& body => $id \& ); .Ve .PP The \f(CW\*(C`clear_scroll()\*(C'\fR method can clear unfinished scroll requests, freeing up resources on the server. .ie n .SS """scroll_helper()""" .el .SS "\f(CWscroll_helper()\fP" .IX Subsection "scroll_helper()" .Vb 1 \& $scroll_helper = $e\->scroll_helper( @args ); .Ve .PP Returns a new instance of the class specified in the \*(L"scroll_helper_class\*(R", which defaults to Search::Elasticsearch::Scroll. .ie n .SS """msearch()""" .el .SS "\f(CWmsearch()\fP" .IX Subsection "msearch()" .Vb 3 \& $results = $e\->msearch( \& index => \*(Aqdefault_index\*(Aq | \e@indices, # optional \& type => \*(Aqdefault_type\*(Aq | \e@types, # optional \& \& body => [ searches ] # required \& ); .Ve .PP The \f(CW\*(C`msearch()\*(C'\fR method allows you to perform multiple searches in a single request. Similar to the \*(L"\fBbulk()\fR\*(R" request, each search request in the \&\f(CW\*(C`body\*(C'\fR consists of two hashes: the metadata hash then the search request hash (the same data that you'd specify in the \f(CW\*(C`body\*(C'\fR of a \*(L"\fBsearch()\fR\*(R" request). For instance: .PP .Vb 7 \& $results = $e\->msearch( \& index => \*(Aqdefault_index\*(Aq, \& type => [\*(Aqdefault_type_1\*(Aq, \*(Aqdefault_type_2\*(Aq], \& body => [ \& # uses defaults \& {}, \& { query => { match_all => {} }}, \& \& # uses a custom index \& { index => \*(Aqnot_the_default_index\*(Aq }, \& { query => { match_all => {} }} \& ] \& ); .Ve .PP Query string parameters: \f(CW\*(C`search_type\*(C'\fR .PP See the msearch docs for more information. .ie n .SS """explain()""" .el .SS "\f(CWexplain()\fP" .IX Subsection "explain()" .Vb 4 \& $response = $e\->explain( \& index => \*(Aqmy_index\*(Aq, # required \& type => \*(Aqmy_type\*(Aq, # required \& id => 123, # required \& \& body => { search } # required \& ); .Ve .PP The \f(CW\*(C`explain()\*(C'\fR method explains why the specified document did or did not match a query, and how the relevance score was calculated. For instance: .PP .Vb 10 \& $response = $e\->explain( \& index => \*(Aqmy_index\*(Aq, \& type => \*(Aqmy_type\*(Aq, \& id => 123, \& body => { \& query => { \& match => { title => \*(AqElasticsearch clients\*(Aq } \& } \& } \& ); .Ve .PP Query string parameters: \f(CW\*(C`_source\*(C'\fR, \f(CW\*(C`_source_exclude\*(C'\fR, \f(CW\*(C`_source_include\*(C'\fR, \f(CW\*(C`analyze_wildcard\*(C'\fR, \f(CW\*(C`analyzer\*(C'\fR, \f(CW\*(C`default_operator\*(C'\fR, \f(CW\*(C`df\*(C'\fR, \f(CW\*(C`fields\*(C'\fR, \f(CW\*(C`lenient\*(C'\fR, \f(CW\*(C`lowercase_expanded_terms\*(C'\fR, \f(CW\*(C`parent\*(C'\fR, \f(CW\*(C`preference\*(C'\fR, \f(CW\*(C`q\*(C'\fR, \f(CW\*(C`routing\*(C'\fR .PP See the explain docs for more information. .ie n .SS """field_stats()""" .el .SS "\f(CWfield_stats()\fP" .IX Subsection "field_stats()" .Vb 5 \& $response = $e\->field_stats( \& index => \*(Aqindex\*(Aq | \e@indices, # optional \& fields => \*(Aqfield\*(Aq | \e@fields, # optional \& level => \*(Aqcluster\*(Aq | \*(Aqindices\*(Aq, # optional \& ); .Ve .PP The \f(CW\*(C`field\-stats\*(C'\fR \s-1API\s0 returns statistical properties of a field (such as min and max values) without executing a search. .PP Query string parameters: \f(CW\*(C`allow_no_indices\*(C'\fR, \f(CW\*(C`expand_wildcards\*(C'\fR, \f(CW\*(C`fields\*(C'\fR, \f(CW\*(C`ignore_unavailable\*(C'\fR, \f(CW\*(C`level\*(C'\fR .PP See the field-stats docs for more information. .ie n .SS """search_shards()""" .el .SS "\f(CWsearch_shards()\fP" .IX Subsection "search_shards()" .Vb 4 \& $response = $e\->search_shards( \& index => \*(Aqindex\*(Aq | \e@indices, # optional \& type => \*(Aqtype\*(Aq | \e@types, # optional \& ) .Ve .PP The \f(CW\*(C`search_shards()\*(C'\fR method returns information about which shards on which nodes will execute a search request. .PP Query string parameters: \f(CW\*(C`allow_no_indices\*(C'\fR, \f(CW\*(C`expand_wildcards\*(C'\fR, \f(CW\*(C`ignore_unavailable\*(C'\fR, \f(CW\*(C`local\*(C'\fR, \f(CW\*(C`preference\*(C'\fR, \f(CW\*(C`routing\*(C'\fR .PP See the search-shards docs for more information. .SH "PERCOLATION METHODS" .IX Header "PERCOLATION METHODS" .ie n .SS """percolate()""" .el .SS "\f(CWpercolate()\fP" .IX Subsection "percolate()" .Vb 3 \& $results = $e\->percolate( \& index => \*(Aqmy_index\*(Aq, # required \& type => \*(Aqmy_type\*(Aq, # required \& \& body => { percolation } # required \& ); .Ve .PP Percolation is search inverted: instead of finding docs which match a particular query, it finds queries which match a particular document, eg for \fIalert-me-when\fR functionality. .PP The \f(CW\*(C`percolate()\*(C'\fR method runs a percolation request to find the queries matching a particular document. In the \f(CW\*(C`body\*(C'\fR you should pass the \&\f(CW\*(C`_source\*(C'\fR field of the document under the \f(CW\*(C`doc\*(C'\fR key: .PP .Vb 9 \& $results = $e\->percolate( \& index => \*(Aqmy_index\*(Aq, \& type => \*(Aqmy_type\*(Aq, \& body => { \& doc => { \& title => \*(AqElasticsearch rocks\*(Aq \& } \& } \& ); .Ve .PP Query string parameters: \f(CW\*(C`allow_no_indices\*(C'\fR, \f(CW\*(C`expand_wildcards\*(C'\fR, \f(CW\*(C`ignore_unavailable\*(C'\fR, \f(CW\*(C`percolate_format\*(C'\fR, \f(CW\*(C`percolate_index\*(C'\fR, \f(CW\*(C`percolate_preference\*(C'\fR, \f(CW\*(C`percolate_routing\*(C'\fR, \f(CW\*(C`percolate_type\*(C'\fR, \f(CW\*(C`preference\*(C'\fR, \f(CW\*(C`routing\*(C'\fR, \f(CW\*(C`version\*(C'\fR, \f(CW\*(C`version_type\*(C'\fR .PP See the percolate docs for more information. .ie n .SS """count_percolate()""" .el .SS "\f(CWcount_percolate()\fP" .IX Subsection "count_percolate()" .Vb 3 \& $results = $e\->count_percolate( \& index => \*(Aqmy_index\*(Aq, # required \& type => \*(Aqmy_type\*(Aq, # required \& \& body => { percolation } # required \& ); .Ve .PP The \*(L"\fBcount_percolate()\fR\*(R" request works just like the \*(L"\fBpercolate()\fR\*(R" request except that it returns a count of all matching queries, instead of the queries themselves. .PP .Vb 9 \& $results = $e\->count_percolate( \& index => \*(Aqmy_index\*(Aq, \& type => \*(Aqmy_type\*(Aq, \& body => { \& doc => { \& title => \*(AqElasticsearch rocks\*(Aq \& } \& } \& ); .Ve .PP Query string parameters: \f(CW\*(C`allow_no_indices\*(C'\fR, \f(CW\*(C`expand_wildcards\*(C'\fR, \f(CW\*(C`ignore_unavailable\*(C'\fR, \f(CW\*(C`percolate_index\*(C'\fR, \f(CW\*(C`percolate_type\*(C'\fR, \f(CW\*(C`preference\*(C'\fR, \f(CW\*(C`routing\*(C'\fR, \f(CW\*(C`version\*(C'\fR, \f(CW\*(C`version_type\*(C'\fR .PP See the percolate docs for more information. .ie n .SS """mpercolate()""" .el .SS "\f(CWmpercolate()\fP" .IX Subsection "mpercolate()" .Vb 3 \& $results = $e\->mpercolate( \& index => \*(Aqmy_index\*(Aq, # required if type \& type => \*(Aqmy_type\*(Aq, # optional \& \& body => [ percolation requests ] # required \& ); .Ve .PP Multi-percolation allows multiple \*(L"\fBpercolate()\fR\*(R" requests to be run in a single request. .PP .Vb 10 \& $results = $e\->mpercolate( \& index => \*(Aqmy_index\*(Aq, \& type => \*(Aqmy_type\*(Aq, \& body => [ \& # first request \& { percolate => { \& index => \*(Aqtwitter\*(Aq, \& type => \*(Aqtweet\*(Aq \& }}, \& { doc => {message => \*(Aqsome_text\*(Aq }}, \& \& # second request \& { percolate => { \& index => \*(Aqtwitter\*(Aq, \& type => \*(Aqtweet\*(Aq, \& id => 1 \& }}, \& {}, \& ] \& ); .Ve .PP Query string parameters: \f(CW\*(C`allow_no_indices\*(C'\fR, \f(CW\*(C`expand_wildcards\*(C'\fR, \f(CW\*(C`ignore_unavailable\*(C'\fR .PP See the mpercolate docs for more information. .ie n .SS """suggest()""" .el .SS "\f(CWsuggest()\fP" .IX Subsection "suggest()" .Vb 2 \& $results = $e\->suggest( \& index => \*(Aqindex\*(Aq | \e@indices, # optional \& \& body => { suggest request } # required \& ); .Ve .PP The \f(CW\*(C`suggest()\*(C'\fR method is used to run did-you-mean or search-as-you-type suggestion requests, which can also be run as part of a \*(L"\fBsearch()\fR\*(R" request. .PP .Vb 11 \& $results = $e\->suggest( \& index => \*(Aqmy_index\*(Aq, \& body => { \& my_suggestions => { \& phrase => { \& text => \*(Aqjohnny walker\*(Aq, \& field => \*(Aqtitle\*(Aq \& } \& } \& } \& ); .Ve .PP Query string parameters: \f(CW\*(C`allow_no_indices\*(C'\fR, \f(CW\*(C`expand_wildcards\*(C'\fR, \f(CW\*(C`ignore_unavailable\*(C'\fR, \f(CW\*(C`preference\*(C'\fR, \f(CW\*(C`routing\*(C'\fR .ie n .SS """mlt()""" .el .SS "\f(CWmlt()\fP" .IX Subsection "mlt()" .Vb 4 \& $results = $e\->mlt( \& index => \*(Aqmy_index\*(Aq, # required \& type => \*(Aqmy_type\*(Aq, # required \& id => 123, # required \& \& body => { search } # optional \& ); .Ve .PP The \f(CW\*(C`mlt()\*(C'\fR method runs a more-like-this query to find other documents which are similar to the specified document. .PP Query string parameters: \f(CW\*(C`boost_terms\*(C'\fR, \f(CW\*(C`max_doc_freq\*(C'\fR, \f(CW\*(C`max_query_terms\*(C'\fR, \f(CW\*(C`max_word_length\*(C'\fR, \f(CW\*(C`min_doc_freq\*(C'\fR, \f(CW\*(C`min_term_freq\*(C'\fR, \f(CW\*(C`min_word_length\*(C'\fR, \f(CW\*(C`mlt_fields\*(C'\fR, \f(CW\*(C`percent_terms_to_match\*(C'\fR, \f(CW\*(C`routing\*(C'\fR, \f(CW\*(C`search_from\*(C'\fR, \f(CW\*(C`search_indices\*(C'\fR, \f(CW\*(C`search_scroll\*(C'\fR, \f(CW\*(C`search_size\*(C'\fR, \f(CW\*(C`search_source\*(C'\fR, \f(CW\*(C`search_type\*(C'\fR, \f(CW\*(C`search_types\*(C'\fR, \f(CW\*(C`stop_words\*(C'\fR .PP See the mlt docs for more information. .SH "INDEXED SCRIPT METHODS" .IX Header "INDEXED SCRIPT METHODS" If dynamic scripting is enabled, Elasticsearch allows you to store scripts in an internal index known as \&\f(CW\*(C`.scripts\*(C'\fR and reference them by id. The methods to manage indexed scripts are as follows: .ie n .SS """put_script()""" .el .SS "\f(CWput_script()\fP" .IX Subsection "put_script()" .Vb 5 \& $result = $e\->put_script( \& lang => \*(Aqlang\*(Aq, # required \& id => \*(Aqid\*(Aq, # required \& body => { script } # required \& ); .Ve .PP The \f(CW\*(C`put_script()\*(C'\fR method is used to store a script in the \f(CW\*(C`.scripts\*(C'\fR index. For instance: .PP .Vb 7 \& $result = $e\->put_scripts( \& lang => \*(Aqgroovy\*(Aq, \& id => \*(Aqhello_world\*(Aq, \& body => { \& script => q(return "hello world"); \& } \& ); .Ve .PP Query string parameters: \f(CW\*(C`op_type\*(C'\fR, \f(CW\*(C`version\*(C'\fR, \f(CW\*(C`version_type\*(C'\fR .PP See the indexed scripts docs for more. .ie n .SS """get_script()""" .el .SS "\f(CWget_script()\fP" .IX Subsection "get_script()" .Vb 4 \& $script = $e\->get_script( \& lang => \*(Aqlang\*(Aq, # required \& id => \*(Aqid\*(Aq, # required \& ); .Ve .PP Retrieve the indexed script from the \f(CW\*(C`.scripts\*(C'\fR index. .PP Query string parameters: \f(CW\*(C`version\*(C'\fR, \f(CW\*(C`version_type\*(C'\fR .PP See the indexed scripts docs for more. .ie n .SS """delete_script()""" .el .SS "\f(CWdelete_script()\fP" .IX Subsection "delete_script()" .Vb 4 \& $script = $e\->delete_script( \& lang => \*(Aqlang\*(Aq, # required \& id => \*(Aqid\*(Aq, # required \& ); .Ve .PP Delete the indexed script from the \f(CW\*(C`.scripts\*(C'\fR index. .PP Query string parameters: \f(CW\*(C`version\*(C'\fR, \f(CW\*(C`version_type\*(C'\fR .PP See the indexed scripts docs for more. .SH "INDEXED SEARCH TEMPLATE METHODS" .IX Header "INDEXED SEARCH TEMPLATE METHODS" Mustache templates can be used to create search requests. These templates can be stored in the \f(CW\*(C`.scripts\*(C'\fR index and retrieved by \s-1ID.\s0 The methods to manage indexed scripts are as follows: .ie n .SS """put_template()""" .el .SS "\f(CWput_template()\fP" .IX Subsection "put_template()" .Vb 4 \& $result = $e\->put_template( \& id => \*(Aqid\*(Aq, # required \& body => { template } || "template" # required \& ); .Ve .PP The \f(CW\*(C`put_template()\*(C'\fR method is used to store a template in the \f(CW\*(C`.scripts\*(C'\fR index. For instance: .PP .Vb 12 \& $result = $e\->put_template( \& id => \*(Aqhello_world\*(Aq, \& body => { \& template => { \& query => { \& match => { \& title => "hello world" \& } \& } \& } \& } \& ); .Ve .PP Query string parameters: None .PP See the indexed search template docs for more. .ie n .SS """get_template()""" .el .SS "\f(CWget_template()\fP" .IX Subsection "get_template()" .Vb 3 \& $script = $e\->get_template( \& id => \*(Aqid\*(Aq, # required \& ); .Ve .PP Retrieve the indexed template from the \f(CW\*(C`.scripts\*(C'\fR index. .PP Query string parameters: \f(CW\*(C`version\*(C'\fR, \f(CW\*(C`version_type\*(C'\fR .PP See the indexed search template docs for more. .ie n .SS """delete_template()""" .el .SS "\f(CWdelete_template()\fP" .IX Subsection "delete_template()" .Vb 3 \& $script = $e\->delete_template( \& id => \*(Aqid\*(Aq, # required \& ); .Ve .PP Delete the indexed template from the \f(CW\*(C`.scripts\*(C'\fR index. .PP Query string parameters: None .PP See the indexed search template docs for more. .SH "AUTHOR" .IX Header "AUTHOR" Enrico Zimuel .SH "COPYRIGHT AND LICENSE" .IX Header "COPYRIGHT AND LICENSE" This software is Copyright (c) 2020 by Elasticsearch \s-1BV.\s0 .PP This is free software, licensed under: .PP .Vb 1 \& The Apache License, Version 2.0, January 2004 .Ve