Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Elasticsearch: is bulk search possible?

i know there is support for bulk index operation. but is it possible to do the same for search queries? i want to send many different unrelated queries (to do precision/recall testing) and it would probably be faster using bulk query

like image 807
piotrek Avatar asked Jan 20 '16 12:01

piotrek


People also ask

Is Elasticsearch good for full-text search?

Elasticsearch is a popular open source search engine. Because of its real-time speeds and robust API, it's a popular choice among developers that need to add full-text search capabilities in their projects.

How do I search multiple fields in Elasticsearch?

One of the most common queries in elasticsearch is the match query, which works on a single field. And there's another query with the very same options that works also on multiple fields, called multi_match. These queries support text analysis and work really well.

What is bulk indexing in Elasticsearch?

Bulk: indexing multiple documentsedit Bulk requests allow sending multiple document-related operations to Elasticsearch in one request.

Is Elasticsearch Difficult?

Elasticsearch is a little industrial and by a little industrial I mean a lot industrial. Interacting with the service is pretty difficult, searching through data is hard and the documentation is cryptic at best; get something wrong and you can expect to sit for 3 hours while your data re-indexes.


1 Answers

Yes, you can use the multi search API and the /_msearch endpoint to send as many queries as you wish in one shot.

curl -XPOST localhost:9200/_msearch -d '
{"index" : "test1"}
{"query" : {"match_all" : {}}, "from" : 0, "size" : 10}
{"index" : "test2"}
{"query" : {"match_all" : {}}}
'

You'll get a responses array with the response of each query in the same order as in the request.

Note:

  1. make sure to separate each line by a newline character
  2. make sure to add the extra newline after the last query.
like image 132
Val Avatar answered Sep 19 '22 12:09

Val