elastic 查询案例Query与Filter + 增删改查简单理解 + dynamic mapping + keyword

1.增  参考:https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping.html

  PUT mytest01/external/1
{
  "name": "xiaowei"
}

curl -XPUT '192.168.1.49:9200/mytest/external/1?format=yaml' -H "Content-Type: application/json" -d '{"name":"paxi"}'

2.查

查看索引:curl -XGET http://192.168.1.49:9200/_cat/indices?pretty
GET mytest/_search/ { "query": { "match": { "name": "paxi" } } } curl -XGET 'http://192.168.1.49:9200/mytest/_search/' -H "Content-Type: application/json" -d '{ "query": { "match": { "name": "paxi" } } }'

 3.删除

curl -XDELETE http://192.168.1.49:9200/mytest01
参考:https://www.cnblogs.com/jing1617/p/8060421.html

 4.查看mapping

 curl -XGET http://192.168.1.49:9200/mytest08/_mapping?pretty

5.查看settings

curl -XGET http://192.168.1.49:9200/mytest08/_settings?pretty

--------------------------------------------------------------------------------------

0.模糊查询好的例子

GET /my_index/my_type/_search
{
  "query": {
    "match": {
      "title": {
        "query": "quick~brow~",
        "fuzziness": "AUTO",
        "operator": "and"
      }
    }
  }
}

参考: https://blog.csdn.net/u011262847/article/details/78007119

1.elasticsearch的devtool短语查询2019-07-18 11:30这个时间的日志document

GET /log47012/doc/_search
{
    "query": {
        "match_phrase": {
            "localtime": "2019-07-18 11:30~"
        }
    }
}

2.kibana的discover的2019-07-18 11:30这个时间的日志document

localtime: "2019-07-18 11:30~"
"2019-07-18 11:30~" --> 相当于一个完整字符串
 

 3.AND discover 查询

"2019-07-18 11:34" AND "中的配置项正在被初始化"

 ——————————————————————————————————————————

1.匹配符查询

# index a doc
PUT index/type/1
{
  "body": "here"
}

# and get it ...
GET index/type/1

### get all index
GET _cat/indices

### get type
GET log4sys-2019.07.19/_search

### query target document
GET log4sys-2019.07.19/doc/_search
{
  "query": {
    "wildcard": {
      "body": "*he?*e"
    }
  }
}

 ----------------------------------------------------------------------------------------------------------------------------------------------

1.查询在Query查询上下文和Filter过滤器上下文中,执行的操作是不一样的:

查询上下文:

在查询上下文中,查询会回答这个问题——“这个文档匹不匹配这个查询,它的相关度高么?”

2.

过滤器上下文:

在过滤器上下文中,查询会回答这个问题——“这个文档匹不匹配?”

 复制自:https://www.cnblogs.com/xing901022/p/4975931.html

https://www.cnblogs.com/asker009/p/10174973.html

命令行查询

curl -X POST 
  http://10.0.0.35:9200/addressbook_user/_search 
  -H 'cache-control: no-cache' 
  -H 'content-type: application/json' 
  -d '{
    "size": 5000,
    "query": {
        "bool": {
            "must": [
                {
                    "term": {
                        "userId": {
                            "value": "03a6cc5f1a6d4326a490ddf3547f3a1a",
                            "boost": 1
                        }
                    }
                }
            ],
         
            "adjust_pure_negative": true,
            "boost": 1
        }
    }
}'
原文地址:https://www.cnblogs.com/hixiaowei/p/11208784.html