elasticsearch - 什么是elasticsearch中query_string中的escape属性

标签 elasticsearch query-string elasticsearch-7

我在elasticsearch的query_string中使用通配符时遇到问题。当值为“true”时,我在query_string中找不到“escape”属性的文档,我得到了一些结果,但是当它为“false”时,结果为零。

{
                    "query_string": {
                        "query": "*Serial\\+*",
                        "fields": [
                            "info.name^1.0"
                        ],
                        "type": "best_fields",
                        "allow_leading_wildcard": true,
                        "analyze_wildcard": true,
                        "escape": true,
                        "auto_generate_synonyms_phrase_query": true,
                        "fuzzy_transpositions": true,
                        "boost": 1.0
                    }
                }
有人可以解释“逃生”属性吗?

最佳答案

奇怪的是它没有记录,但是查看源代码我们可以看到:
Es query string source code
如果“escape”为“true”,则代码调用
org.apache.lucene.queryparser.classic.QueryParser.escape
在查询字符串中,函数本身被记录为

Returns a String where those characters that QueryParser expects to be escaped are escaped by a preceding \.


所以看起来这个标志只是用来为你自动转义字符,所以你不必手动转义它们

关于elasticsearch - 什么是elasticsearch中query_string中的escape属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69149461/

相关文章:

elasticsearch - Elasticsearch原子性保证搜索请求

google-plus - Google Plus 开放图错误 : G+ doesn't recognize open graph image when UTM or other query string appended to URL

javascript - 使用 ajax 时,某些问题页面有一个查询字符串

elasticsearch - Elasticsearch中基于每个用户行为的评分

node.js - constant_score查询不支持在代码中查询

javascript 获取查询字符串

ElasticSearch:存在模板时将文档插入 ElasticSearch 索引的奇怪问题

elasticsearch - 无法在EC2机器上形成Elasticsearch 7集群

elasticsearch - 我可以从 Stormcrawler 获得哪些值/字段?

mysql - 混合 MySQL/非规范化数据存储以优化 REST API 性能