【问题标题】:ElasticSearch Query_String search forward slash excapingElasticSearch Query_String 搜索正斜杠
【发布时间】:2015-04-16 21:20:15
【问题描述】:

我正在尝试为此文件路径编写查询:

C:/This/Is/My/File.txt

像这样:

{
    "query": {
        "query_string": {
           "default_field": "filePath",
           "query": "C:This\\/Is\\/My\\/File.txt"
        }
    }
}

但是它给了我一个错误说:

SearchPhaseExecutionException[未能执行阶段[查询]

所以我假设它与转义有关,但它似乎是正确的。

这里有什么我遗漏的吗?

【问题讨论】:

  • 为什么要使用 query_string 这个,使用 term 查询
  • 我允许用户使用 query_string 格式输入进行搜索...我只需要在我的文档中指定转义 / 他们必须使用 \/

标签: elasticsearch


【解决方案1】:
"query": {
        "query_string": {
           "default_field": "filePath",
           "query": "C\\:\\/NewRevelation\\/PlexMaster\\/Cloud.CDN\\/Content\\/xslt\\/Modules\\/Purchasing\\/Shared\\/Specifications.xslt"
        }
    }

由于在解析输入字符串后需要查看 / 你需要额外的 \

【讨论】:

    猜你喜欢
    • 2022-07-25
    • 1970-01-01
    • 2016-01-18
    • 2011-01-28
    • 1970-01-01
    • 2021-02-14
    • 2019-03-20
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多