es

es相关

lucene语法转换工具,貌似是pyparsing

有的有说是,通用的语法分析器。

https://www.cnblogs.com/carolsun/p/13908402.html

这个教程,比较能解决问题。

python+ elasticsearch + lucene使用

https://blog.csdn.net/weixin_45143622/article/details/113843127

Lucene查询语法详解

https://www.cnblogs.com/xing901022/p/4974977.html

单纯的es查询语法

https://blog.csdn.net/mon_star/article/details/102934620

https://www.cnblogs.com/xiohao/p/12970224.html

grafana

grafana像sql一样展示elasticsearch数据源指定的字段数据

https://blog.csdn.net/qq_23598037/article/details/99852350

lucene查询语法

https://blog.csdn.net/weixin_44141000/article/details/111667275

其他

https://www.cnblogs.com/shaosks/p/7592229.html

python连接

from elasticsearch import Elasticsearch
from elasticsearch import helpers

es_host = https://es-sta.pamirs.com
es_auth = elastic:123456
es= Elasticsearch(hosts=[es_host], http_auth=es_auth,
                   sniff_on_connection_fail=True,
                   sniff_timeout=60,
                   )

#数据大量插入到es
action=[]
for n in total:
    dic_one={
        '_index': 'expert_experts',
        '_type': '_doc',
        '_id':n[0],
        '_source':
            {   'id':n[0],
        'name': n[1]
                }
    }
    action.append(dic_one)
helpers.bulk(self.es, action)

直接使用grafana的接口

https://www.pianshen.com/article/4860999595/

获取数据,只能通过控制台,调试,查看真正的数据。

包含查询的一些基本接口。

https://www.cnblogs.com/gangdou/p/12986667.html

php

es搜索遇到的问题

http://www.lmonkey.com/t/wDEx70KBK

具体内容

$result = Product::searchRaw( [
            "query" => [
                "bool" => [
                    "must" => [
                        [
                            "match" => [
                                "category_id" => $categoryId
                            ]
                        ]
                    ]
                ]
            ],
            "aggs"  => [
                "single_category_avg_price" => [
                    "avg" => [
                        "field" => "price"
                    ]
                ],
                "all"                       => [
                    "global" =>new \stdClass(),//修改这里 传递对象
                    "aggs"   => [
                        "all_category_avg_price" => [
                            "avg" => [
                                "field" => "price"
                            ]
                        ]
                    ]
                ]
            ]
        ] );

curl



curl  -H "Content-Type: application/json" -XGET http://10.65.0.33:9200/online/senseLog/_search?pretty -d ' {"query":{"match_all":{}}}'


curl -k -u admin:admin -XGET https://xxx:9200/_cluster/health?pretty

示例

使用curl来请求

curl -H "Content-Type: application/json" -XGET http://ip:9200/su2-f5-http-*/_doc/_search?pretty -u 'user:password' -d '
{
    "size": 0,
    "query": {
        "bool": {
            "filter": [
                {
                    "range": {
                        "@timestamp": {
                            "gte": 1644297032000,
                            "lte": 1644307832000,
                            "format": "epoch_millis"
                        }
                    }
                },
                {
                    "query_string": {
                        "analyze_wildcard": true,
                        "query": "virtual_ip:\"10.182.10.7\" AND virtual_port:30134 AND (server_port:30441) AND NOT clientip:10.131.213.103 AND NOT clientip:10.131.202.21"
                    }
                }
            ]
        }
    }
}
' 

lucene