1

I have a requirement in which I want to search two or more search index when a particular query is being submitted to search server. Is there a way in which I can collectively search two or more search indexes (all of them indexes different things about the same entity being searched for) and get a single set of responses (response from two or more search indexes) when using Lucene/Solr/Elasticsearch? If this is not possible I am trying to set up something on the API level where the search indexes are abstracted away from the search clients where the query is submitted to the API & the API under the hood launces searches in parallel to two or more search indexes and combines the results and sends it back?

The point here is that I don't want to reinvent the wheel if there is such an API framework is available or even if its possible using Lucene/Solr/Elasticsearch out of the box or by simply installing a plugin & configuring it?

techcraver
  • 401
  • 3
  • 21

1 Answers1

1

You can easily do this using elasticsearch. While searching you can mention the indices names in a comma separated format like below -

curl -XPOST 'http://localhost:9200/index-a,index-b,index-c/_search -d '{
  "query": {
    "match_all": {}
  }
}'

For convenience sake , you can also use aliases. Alias can bind to multiple index names and you can use a single alias to talk to all those indices

Vineeth Mohan
  • 18,633
  • 8
  • 63
  • 77
  • I think that this would resolve the problem that I'm looking for. How ever can you please suggest any configuration based approach for the same? I don't want to add a dependency on the indice names to be hardwired to application and I should be able to dynamically add/remove indexes on the go. Is there a way to do it? – techcraver Apr 08 '15 at 05:08
  • I have mentioined about aliases in my answer. You can use that. Instead of index name , you can hit the alias and alias will resolve to mutiple index names. You can hence abstract out multiple index name information from the user. – Vineeth Mohan Apr 08 '15 at 05:19