Elasticsearch是一个基于Lucene库的搜索引擎。它提供了一个分布式的、支持多租户的全文搜索引擎,带有HTTP web接口和无模式的JSON文档。Elasticsearch提供了Kibana,用于Elasticsearch的开源数据可视化仪表板。
在特定的情况我们没有界面可以看,只能通过命令行来访问获取ES中数据和结构,这时Curl命令就派上用场了。
搜索请求可以使用搜索DSL(其中包括查询DSL)来执行。
GET /<index>/_search
{
"query": {<parameters>}
}
例子:
GET /twitter/_search
{
"query" : {
"term" : { "user" : "kimchy" }
}
}
curl -XGET http://10.168.0.2:9200/<index>/_mapping?pretty
curl -X POST http://10.168.0.2:9200/<index>/_search -H "Content-Type:application/json" -d '{"query": {"bool": {"filter": [{"terms": {"id": [24, 26 ] } } ] } } }'
{
"query": {
"constant_score": {
"filter": {
"bool": {
"filter": [
{
"term": {
"disabled": true
}
},
{
"terms": {
"id": [
24,
902,
915
]
}
}
],
"must_not": [
{
"terms": {
"country_ex": [
"in"
]
}
}
]
}
}
}
},
"sort": {
"id": {
"order": "desc"
}
}
}'