如何在不使用特殊 SQL elasticSearch 运算符的情况下在 elastic 的文本字段上使用标准 SQL?

How can I use standard SQL on text fields of elastic without using the specials SQL elasticSearch operators?

我想在某些文本字段(不是关键字)上创建 SQL 查询,例如“名称”字段,并将该查询发送到弹性服务器。

我的问题是我需要使用文本字段的标准 SQL 语言(不是弹性 SQL 特有的 MATCH 和 QUERY 运算符)。

当我尝试使用 JDBC 驱动程序或当我尝试使用带有 LIKE 运算符的高级-java-客户端时我收到以下错误

  "No keyword/multi-field defined exact matches for [name]; define one or use MATCH/QUERY instead"

我还尝试使用 elasticsearch 的翻译 API - 但即使在那里我也无法仅在关键字字段上的文本字段上使用“LIKE”运算符。

有人能帮我解决吗?我想在文本字段上使用 LIKE 运算符,而不是弹性 sql.

独有的全文运算符

请查看 this 文档。他们在文档中明确提到这是不可能的。

One significant difference between LIKE/RLIKE and the full-text search predicates is that the former act on exact fields while the latter also work on analyzed fields. If the field used with LIKE/RLIKE doesn’t have an exact not-normalized sub-field (of keyword type) Elasticsearch SQL will not be able to run the query. If the field is either exact or has an exact sub-field, it will use it as is, or it will automatically use the exact sub-field even if it wasn’t explicitly specified in the statement.

如果您仍想使用文本字段,则需要启用 multi-field,如前所述 here。或者您可以尝试在文本字段上启用 fielddata,但我不确定它是否有效 SQL。