在ElasticSearch中针对多个索引下的所有字段运行精确短语匹配

时间:2015-11-20 09:55:37

标签: java elasticsearch

我需要针对多个索引下的所有字段运行精确的词组匹配。

弹性java api有一个方法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);
    }

问题是它需要字段名称来运行匹配短语查询。 而我需要针对多个索引下的所有字段运行。

有没有办法实现这个目标?

1 个答案:

答案 0 :(得分:0)

在匹配阶段查询方法中,字段名称将

  

“_所有”

matchPhraseQuery("_all", Object text){}