如何使用 Elastic Java Api 而不是纯 REST 构建类型设置为 "phrase_prefix" 的多匹配查询
How to build multi match query with type set to "phrase_prefix" using Elastic Java Api instead of pure REST
根据多匹配查询的文档 (https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-multi-match-query.html) it is possible to search multi properties by prefix. All you must do is to set parameter "type" to "phrase_prefix". Unfortunately I cannot find that option in Elastic Java Api (https://www.elastic.co/guide/en/elasticsearch/client/java-api/1.6/multimatch.html)。我试过类似的东西:
QueryBuilder builder = QueryBuilders
.multiMatchQuery("query", "property1", "property2");
但找不到设置 "type" 参数的位置。我知道纯粹的休息是解决方案,但我仅限于 java api.
我使用的是 org.elasticsearch.client:transport.
的 5.2.2 版
您必须将 .type(MatchQueryBuilder.Type.PHRASE_PREFIX)
添加到您的构建器。
示例:
QueryBuilder builder = QueryBuilders
.multiMatchQuery("query", "property1", "property2")
.type(MatchQuery.Type.PHRASE_PREFIX)
根据多匹配查询的文档 (https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-multi-match-query.html) it is possible to search multi properties by prefix. All you must do is to set parameter "type" to "phrase_prefix". Unfortunately I cannot find that option in Elastic Java Api (https://www.elastic.co/guide/en/elasticsearch/client/java-api/1.6/multimatch.html)。我试过类似的东西:
QueryBuilder builder = QueryBuilders
.multiMatchQuery("query", "property1", "property2");
但找不到设置 "type" 参数的位置。我知道纯粹的休息是解决方案,但我仅限于 java api.
我使用的是 org.elasticsearch.client:transport.
的 5.2.2 版您必须将 .type(MatchQueryBuilder.Type.PHRASE_PREFIX)
添加到您的构建器。
示例:
QueryBuilder builder = QueryBuilders
.multiMatchQuery("query", "property1", "property2")
.type(MatchQuery.Type.PHRASE_PREFIX)