Elasticsearch Java HighLevelRestClient 如何创建not_analyzed 索引?

Elasticsearch Java HighLevelRestClient how to create not_analyzed index?

我正在使用 HighLevelRestClient 7.4.0,我很好奇如何在使用索引 API.

索引文档时创建 not_analyzed 字段

问题是我正在尝试按片名搜索电影,如果我搜索 "matrix" 它 returns 正确的结果,但如果我搜索 "The matrix" 它returns 几乎每部电影的标题中都有 "the"(matchQuery 就是这种情况)。

我改为使用 termQuery,但现在当我搜索 "matrix" 时,它 returns 是正确的结果,当我搜索 "Matrix" 时,它没有找到任何东西,同样是"the matrix".

的情况

我猜问题是当我为文档编制索引时,默认情况下会分析每个文本字段。我如何创建 not_analyzed 索引?

现在我正在通过使用 GSON 将数据结构简单地转换为 Json 来索引电影。

为了正确执行搜索,我不得不使用 matchPhraseQuery 而不是 matchQuery 或 termQuery。