Search across all indexed fields, returning the ids of the documents which match the query.
This will perform a full-text style query across all fields. The query string supports the Lucene query parser syntax and hence filters on specific fields (e.g. fieldname:value), wildcards (e.g. abc*) as well as a variety of options.
var ElasticSearch = require('machinepack-elasticsearch');
// Search across all indexed fields, returning the ids of the documents which match the query.
ElasticSearch.search({
hostname: 'localhost',
index: 'myindex',
query: 'cute dogs',
port: 9200,
}).exec({
// An unexpected error occurred.
error: function (err) {
},
// Could not connect to ElasticSearch at the provided hostname and port, or all connections in the ES client pool are "dead".
couldNotConnect: function () {
},
// The specified index does not exist
noSuchIndex: function () {
},
// OK.
success: function (result) {
},
});
The hostname of your ElasticSearch server
'localhost'
The name of the index to search
'myindex'
The search query
'cute dogs'
The port your ElasticSearch server is running on
9200
An unexpected error occurred.
Could not connect to ElasticSearch at the provided hostname and port, or all connections in the ES client pool are "dead".
The specified index does not exist
OK.
[ 'f1913a1011-21940a0b1315-1939a193e1' ]