Elasticsearch 简单查询字符串查询 vs 精确文本搜索

Elasticsearch simple query string query vs exact text search

我有一个包含多个字段的文档。

文件

我想使用 google 进行搜索,例如

当我使用 "blue car" 时,它必须是完全匹配的精确值,根本没有任何分析。它必须只找到没有词干等的确切短语

为此我得到了这样的工作版本 ->

{
  "query": {
    "multi_match": {
      "query": "blue car",
      "fields": [
        "text",
        "message",
        "whatever"
      ],
      "type": "phrase"
    }
  }
}

尽管对于其他类型的搜索,例如 -diesel 或 +hybrid。我正在考虑使用 as 似乎可以很好地支持它。

{
   "query": {
        "simple_query_string": {
           "fields": [
            "text",
            "message",
            "whatever"],
           "default_operator": "and",
           "query": "-diesel +hybrid"
        }
     }
}

不幸的是,简单的查询字符串查询将使用分析器,即使我在查询中将文本放在引号中也是如此。

你们知道我如何将两者结合起来吗?我可以使用 bool 查询将它们组合在一起吗?

这是使用 bool query

查询 "blue car" -diesel +hybrid' 的示例
{
    "query": {
        "bool": {
            "must": [
                {
                    "multi_match": {
                        "query": "blue car",
                        "fields": [
                            "text",
                            "message",
                            "whatever"
                        ],
                        "type": "phrase"
                    }
                },
                {
                    "multi_match": {
                        "query": "hybrid",
                        "fields": [
                            "text",
                            "message",
                            "whatever"
                        ]
                    }
                }
            ],
            "must_not": {
                "multi_match": {
                    "query": "diesel",
                    "fields": [
                        "text",
                        "message",
                        "whatever"
                    ]
                }
            }
        }
    }
}