Elasticsearch multisearch returns 错误响应但单个查询 returns 正确响应
Elasticsearch multisearch returns wrong response but single query returns correct response
运行 使用官方 python 客户端在 Elasticsearch 上进行以下查询 returns 错误响应,但 运行 将它们分开给出正确答案。
以下对象作为 search_doc 传递给 elasticsearch.msearch()
:
[
{
'type': 1,
'index': 'xyz'
},
{
'query': {
'bool': {
'must': [
{
'match_phrase': {
'messageid': 'DEL_1CKCJAR'
}
},
{
'regexp': {
'dsn': '2.[0-9].[0-9]'
}
}
]
}
}
},
{
'type': 1,
'index': 'xyz'
},
{
'query': {
'bool': {
'must': [
{
'match_phrase': {
'messageid': 'DEL_1CKCJAR'
}
},
{
'regexp': {
'dsn': '5.[0-9].[0-9]'
}
}
]
}
}
},
{
'type': 1,
'index': 'xyz'
},
{
'query': {
'bool': {
'must': [
{
'match_phrase': {
'messageid': 'DEL_1CKCJAR'
}
},
{
'regexp': {
'dsn': '4.[0-9].[0-9]'
}
}
]
}
}
}
]
和returns以下响应:
[
{
'took': 42,
'hits': {
'hits': [
],
'total': 0,
'max_score': None
},
'status': 200,
'timed_out': False,
'_shards': {
'failed': 0,
'total': 5,
'successful': 5
}
},
{
'took': 41,
'hits': {
'hits': [
],
'total': 0,
'max_score': None
},
'status': 200,
'timed_out': False,
'_shards': {
'failed': 0,
'total': 5,
'successful': 5
}
},
{
'took': 41,
'hits': {
'hits': [
],
'total': 0,
'max_score': None
},
'status': 200,
'timed_out': False,
'_shards': {
'failed': 0,
'total': 5,
'successful': 5
}
}
]
但是,运行单独对索引xyz
进行了如下查询:
{
'query': {
'bool': {
'must': [
{
'match_phrase': {
'messageid': 'DEL_1CKCJAR'
}
},
{
'regexp': {
'dsn': '4.[0-9].[0-9]'
}
}
]
}
}
}
returns 以下回复:
{
"took": 6,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"failed": 0
},
"hits": {
"total": 18,
"max_score": 2.7300916,
"hits": [
{
"_index": "xyz",
"_type": "log",
"_id": "3A91F141442",
"_score": 2.7300916,
"_source": {
"pid": "13034",
"type": "log",
"logsource": "localhost",
"qid": "3A91F141442",
"@timestamp": "2017-06-05T16:44:16.177Z",
"@version": "1",
"host": "localhost.localdomain",
"client": "unknown[XXX.XXX.XXX.XXX]",
"messageid": "20170606062113.12268.36913.DEL_1CKCJAR@localhost.localdomain>",
"nrcpt": "1",
"queuestatus": "queue active",
"size": "1297",
"from": "asdfasdfasdf@gmail.com",
"reason": "(connect to mx2.hotmail.com[XXX.XXX.XXX.XXX]:25: Connection timed out)",
"relayhost": "none",
"result": "deferred",
"delay": "8707",
"to": "abcdefg@outlook.com",
"dsn": "4.4.1"
}
},
....
}
,这是所需的响应。到目前为止,我无法弄清楚为什么个别请求有效但 multi_search 请求无效。
注意:搜索的数据为Elasticsearch日志数据。
感谢任何帮助。 :)
我会说你的多搜索查询使用了错误的 type
:
{
'type': 1,
'index': 'xyz'
}
由您的单个搜索查询 return 编辑的文档具有 log
类型。完全省略类型或使用 log
,您的查询应该 return 所需的结果。
运行 使用官方 python 客户端在 Elasticsearch 上进行以下查询 returns 错误响应,但 运行 将它们分开给出正确答案。
以下对象作为 search_doc 传递给 elasticsearch.msearch()
:
[
{
'type': 1,
'index': 'xyz'
},
{
'query': {
'bool': {
'must': [
{
'match_phrase': {
'messageid': 'DEL_1CKCJAR'
}
},
{
'regexp': {
'dsn': '2.[0-9].[0-9]'
}
}
]
}
}
},
{
'type': 1,
'index': 'xyz'
},
{
'query': {
'bool': {
'must': [
{
'match_phrase': {
'messageid': 'DEL_1CKCJAR'
}
},
{
'regexp': {
'dsn': '5.[0-9].[0-9]'
}
}
]
}
}
},
{
'type': 1,
'index': 'xyz'
},
{
'query': {
'bool': {
'must': [
{
'match_phrase': {
'messageid': 'DEL_1CKCJAR'
}
},
{
'regexp': {
'dsn': '4.[0-9].[0-9]'
}
}
]
}
}
}
]
和returns以下响应:
[
{
'took': 42,
'hits': {
'hits': [
],
'total': 0,
'max_score': None
},
'status': 200,
'timed_out': False,
'_shards': {
'failed': 0,
'total': 5,
'successful': 5
}
},
{
'took': 41,
'hits': {
'hits': [
],
'total': 0,
'max_score': None
},
'status': 200,
'timed_out': False,
'_shards': {
'failed': 0,
'total': 5,
'successful': 5
}
},
{
'took': 41,
'hits': {
'hits': [
],
'total': 0,
'max_score': None
},
'status': 200,
'timed_out': False,
'_shards': {
'failed': 0,
'total': 5,
'successful': 5
}
}
]
但是,运行单独对索引xyz
进行了如下查询:
{
'query': {
'bool': {
'must': [
{
'match_phrase': {
'messageid': 'DEL_1CKCJAR'
}
},
{
'regexp': {
'dsn': '4.[0-9].[0-9]'
}
}
]
}
}
}
returns 以下回复:
{
"took": 6,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"failed": 0
},
"hits": {
"total": 18,
"max_score": 2.7300916,
"hits": [
{
"_index": "xyz",
"_type": "log",
"_id": "3A91F141442",
"_score": 2.7300916,
"_source": {
"pid": "13034",
"type": "log",
"logsource": "localhost",
"qid": "3A91F141442",
"@timestamp": "2017-06-05T16:44:16.177Z",
"@version": "1",
"host": "localhost.localdomain",
"client": "unknown[XXX.XXX.XXX.XXX]",
"messageid": "20170606062113.12268.36913.DEL_1CKCJAR@localhost.localdomain>",
"nrcpt": "1",
"queuestatus": "queue active",
"size": "1297",
"from": "asdfasdfasdf@gmail.com",
"reason": "(connect to mx2.hotmail.com[XXX.XXX.XXX.XXX]:25: Connection timed out)",
"relayhost": "none",
"result": "deferred",
"delay": "8707",
"to": "abcdefg@outlook.com",
"dsn": "4.4.1"
}
},
....
}
,这是所需的响应。到目前为止,我无法弄清楚为什么个别请求有效但 multi_search 请求无效。
注意:搜索的数据为Elasticsearch日志数据。
感谢任何帮助。 :)
我会说你的多搜索查询使用了错误的 type
:
{
'type': 1,
'index': 'xyz'
}
由您的单个搜索查询 return 编辑的文档具有 log
类型。完全省略类型或使用 log
,您的查询应该 return 所需的结果。