私はelasticsearchデータベースを正規表現検索しようとしています。
これまでの私のクエリ(機能していません):
#!/usr/bin/env bash
curl -XGET 'http://localhost:9200/logstash-2015.10.27/_search' -d \
'{
query: {
"regexp": {
"@timestamp": {
value: ".*"
}
}
}
}' | python -m json.tool
そして、私が得た結果は
{
"error": "SearchPhaseExecutionException[Failed to execute phase [query], all shards failed; shardFailures {[DqJwlMoTQ3e8nyl4m7amGw][logstash-2015.10.27][0]: SearchParseException[[logstash-2015.10.27][0]: from[-1],size[-1]: Parse Failure [Failed to parse source [{\n query: {\n \"regexp\": {\n \"@timestamp\": {\n value: \".*\"\n }\n }\n }\n}]]]; nested: IllegalArgumentException[Invalid format: \".*\"]; }{[DqJwlMoTQ3e8nyl4m7amGw][logstash-2015.10.27][1]: SearchParseException[[logstash-2015.10.27][1]: from[-1],size[-1]: Parse Failure [Failed to parse source [{\n query: {\n \"regexp\": {\n \"@timestamp\": {\n value: \".*\"\n }\n }\n }\n}]]]; nested: IllegalArgumentException[Invalid format: \".*\"]; }{[DqJwlMoTQ3e8nyl4m7amGw][logstash-2015.10.27][2]: SearchParseException[[logstash-2015.10.27][2]: from[-1],size[-1]: Parse Failure [Failed to parse source [{\n query: {\n \"regexp\": {\n \"@timestamp\": {\n value: \".*\"\n }\n }\n }\n}]]]; nested: IllegalArgumentException[Invalid format: \".*\"]; }{[DqJwlMoTQ3e8nyl4m7amGw][logstash-2015.10.27][3]: SearchParseException[[logstash-2015.10.27][3]: from[-1],size[-1]: Parse Failure [Failed to parse source [{\n query: {\n \"regexp\": {\n \"@timestamp\": {\n value: \".*\"\n }\n }\n }\n}]]]; nested: IllegalArgumentException[Invalid format: \".*\"]; }{[DqJwlMoTQ3e8nyl4m7amGw][logstash-2015.10.27][4]: SearchParseException[[logstash-2015.10.27][4]: from[-1],size[-1]: Parse Failure [Failed to parse source [{\n query: {\n \"regexp\": {\n \"@timestamp\": {\n value: \".*\"\n }\n }\n }\n}]]]; nested: IllegalArgumentException[Invalid format: \".*\"]; }]",
"status": 400
}
私が見つけようとしているイベントはこれです
{
"_index": "logstash-2015.10.27",
"_type": "logs",
"_id": "AVCml4MI2xxzjEtiGou0",
"_version": 1,
"_score": null,
"_source": {
"host": "server",
"@timestamp": "2015-10-27T00:00:00.142Z",
"type_instance": "free",
"plugin": "exec",
"plugin_instance": "available_memory",
"collectd_type": "gauge",
"value": 855,
"@version": "1"
},
"sort": [
1445904000142
]
}
私は物事をグーグルで検索しましたが、運がありません。
========更新==========
私はこれで私のelasticsearchを照会することができました
#!/usr/bin/env bash
curl -XPOST 'http://localhost:9200/logstash-2015.10.27/_search' -d '
{
"query": {
"bool": {
"must": { "range" : { "@timestamp" : { "gte" : "2015-10-27T00:00:01", "lte" : "2015-10-27T00:00:59"} }},
"must": {"regexp" : { "host": "d027.*" }}
}
}
}'