Running an exact phrase match against all fields under multiple indexes in ElasticSearch


(Shivang Sarawagi) #1

I need to run an exact phrase match against all the fields under multiple indices.

The elastic java api has a method matchPhaseQuery

/**
* Creates a text query with type "PHRASE" for the provided field name and text.
*
* @param name The field name.
* @param text The query text (to be analyzed).
*/
public static MatchQueryBuilder matchPhraseQuery(String name, Object text) {
return new MatchQueryBuilder(name, text).type(MatchQueryBuilder.Type.PHRASE);
}
The problem is it requires the field names to run a match phrase query against. Whereas I need to run against all the fields under multiple indices.

Is there any way to achieve this?


(Maarten Roosendaal) #2

Hi,

Use MultiMatch:
https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-multi-match-query.html

Regards,
Maarten


(system) #3