- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
simple_query_string
有什么区别和 query_string
在 Elasticsearch 中?
哪个更适合搜索?
在 Elasticsearch simple_query_string
文档,它们是写的
Unlike the regular
query_string
query, thesimple_query_string
query will never throw an exception and discards invalid parts of the query.
最佳答案
没有简单的答案。这取决于 :)
一般情况下 query_string
专用于更高级的用途。它有更多选项,但正如您所引用的那样,当发送的查询无法作为一个整体进行解析时,它会引发异常。相反 simple_query_string
选项较少,但不会对无效部分抛出异常。
作为一个例子,看看下面的两个查询:
GET _search
{
"query": {
"query_string": {
"query": "hyperspace AND crops",
"fields": [
"description"
]
}
}
}
GET _search
{
"query": {
"simple_query_string": {
"query": "hyperspace + crops",
"fields": [
"description"
]
}
}
}
GET _search
{
"query": {
"query_string": {
"query": "hyperspace AND crops AND",
"fields": [
"description"
]
}
}
}
GET _search
{
"query": {
"simple_query_string": {
"query": "hyperspace + crops +",
"fields": [
"description"
]
}
}
}
simple_query_string
) 中获得结果。第一个(
query_string
)会抛出这样的东西:
{
"error": {
"root_cause": [
{
"type": "query_shard_exception",
"reason": "Failed to parse query [hyperspace AND crops AND]",
"index_uuid": "FWz0DXnmQhyW5SPU3yj2Tg",
"index": "your_index_name"
}
],
"type": "search_phase_execution_exception",
"reason": "all shards failed",
"phase": "query",
"grouped": true,
"failed_shards": [
...
]
},
"status": 400
}
simple_query_string
.多亏了这一点,最终用户即使在查询中犯了错误,也会在每个查询案例中得到一些结果。
query_string
建议一些更高级的用户使用,他们将接受正确查询语法的培训,以便他们知道为什么在每种特定情况下都没有任何结果。
关于elasticsearch - simple_query_string 和 query_string 哪个更好?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53076255/
我确定这已经被问过无数次了,但我无法让它发挥作用, 我正在尝试用查询字符串重写一个 url,我的 url 是例如: http://example.com/articles/index.php?keyw
如果我要创建这样的查询: "query": { "query_string": { "query": "User:mjohnst", "default_field": "Text"
我在ES 5中具有以下映射的索引 { "test-log": { "mappings": { "record": { "properties": {
我的数据库与 Elasticsearch 同步,以优化我们的搜索结果并更快地请求。 我在查询用户时遇到问题,我想通过查询来查找我的用户,它可以是姓名、电话、IP、... 我的实际查询是 query_s
这是我的测试: 使用比赛 {“query”:{“bool”:{“must”:[{“match”:{“name”:{“query”:“ka”}}}},{“term”:{“kind”:“k1 “}}]}}
我在ElasticSearch(我正在使用1.6版)应用程序中有以下查询: { "query":{ "span_multi":{ "match":{
我正在尝试在 Elasticsearch 中使用日期数学进行日期范围查询,但它没有返回任何结果: `query: { bool: { must: { q
我有一个页面显示我的数据库中的数据。在用户看到数据之前,他们有几个选择框,因此他们可以选择以多种不同方式过滤数据,例如选择显示特定时间段内的数据。当我使用 get 方法时,url 看起来类似于下面的内
我有一个包含 field 视频的索引,其值为 1.flv。如果我执行以下查询: "query": { "query_string": { "query": "2.flv"
我正在使用 ElasticSearch (2.4) 和官方 Python 客户端执行简单查询。我的代码: from elasticsearch import Elasticsearch es_clie
当我将表单数据发布到我的服务器时,我的 fastcgi 应用程序能够从 nginx 读取除 QUERY_STRING 之外的所有参数。查看 CONTENT_LENGTH 给出了正确的字符串长度,我的浏
关于 SO 的第一个问题! 我在 apache 2.2.22 上运行 PHP 5.3.10。我只是这样做: Apache 的 error.log 中的输出如下: Array ( [HTTP_
我有一个关于 .htaccess 和 QUERY_STRING 的问题。 我尝试使用我的 htaccess 重定向一个 URL,如下所示: http://mydomain.tld/out/http%3
您好,我有一个奇怪的问题:我的任务是将 WP 页面 (page_id=2) 重定向到同一域上的页面 (about),但是当我使用字符串重定向时: RewriteEngine On RewriteCon
我在这里遇到一个奇怪的问题。我正在将一个(工作)站点移动到一个我无法直接访问的新 apache 服务器(我必须通过两个人才能完成工作)。 该站点使用名为 adframe 的 perl 脚本来解析 ht
假设我有一个索引,并使用以下语句添加了一些文档: POST test/item/_bulk {"id": 1, "text": "one two"} {"id": 2, "text": "one tw
在我的Elasticsearch中,我有一个像这样的文档: "field_4" : [ "ip_address", "127.0.0
我需要的是,elastic 应该在 中搜索多个字段并按字段优先级返回数据。 例如:对于搜索字符串 obil hon , elastic 应该在 fields[title, description, m
我试图得到一个大于 X 且字段等于 Y 的结果。我试过这个: { "sort": { "datapublicacao": "desc" }, "query": {
我想从 query_string 中读取数据。 例如: username=kramsp&password=overfloww123 我想从查询字符串中读取值 query= username=[data
我是一名优秀的程序员,十分优秀!