Elastic-Search Query DSL Demo

GET position2/_search
{
  "query": {
    "match_all": {}
  }
}

DELETE position2
PUT position2
 {
    "mappings":{
        "properties":{
            "title":{
                "type":"text",
                "analyzer": "ik_max_word",
                "search_analyzer": "ik_smart"
            },

            "description":{
                "type":"text",
                "analyzer": "ik_max_word",
                "search_analyzer": "ik_smart"
            },
            "price":{
                "type":"double"
            }
        }
    }
}  

POST position2/_doc 
{ "title": "中华人民共和国", "price":10.1,"description":"小明" }

POST position2/_doc 
{ "title": "中国", "price":10.2,"description":"北京" }

POST position2/_doc 
{ "title": "小明", "price":10.3,"description":"上海" }


GET position2/_search
{
  "query": {
    "match": {
      "title": {
        "query": "中国",
        "analyzer": "ik_smart",
        "fuzziness": 2
      }
    }
  }
}


GET /_analyze
{
  "analyzer": "ik_max_word",
  "text":"中华人民共和国"
}
GET /_analyze
{
  "analyzer": "ik_smart",
  "text":"中华人民共和国"
}

GET /_analyze
{
  "analyzer": "ik_smart",
  "text":"中国人民"
}
GET /_analyze
{
  "analyzer": "ik_max_word",
  "text":"中国"
}

GET /_analyze
{
  "analyzer": "ik_smart",
  "text":"小明"
}

POST _analyze
{
  "analyzer": "standard",
  "text": "The 2 QUICK Brown-Foxes jumped over the lazy dog's bone."
}

POST books/_analyzer
{
    "field":"title",
    "text":"中华人民共和国"
}


GET position1/_search
{
  "query": {
    "match": {
      "title": {
        "query": "中华",
        "operator": "and"
      }
    }
  }
}

GET position1/_search
{
  "query": {
    "match": {
      "title": "小明"
    }
  }
}

GET position1/_search
{
  "query": {
    "range": {
      "price": {
        "gte": 10.5,
        "lte": 11
      }
    }
  }
}

GET position1/_search
{
  "query": {
    "bool": {
      "must": [
        {"term": {"title": "小"} }
      ],
      "filter": [
        {"range": {"price": {"gte": 10.15, "lte": 11}}}
      ]
    }
  }
}

GET position1/_search
{
  "query": {
    "bool": {
      "must": [
        {"match_all": {}}
      ],
      "filter": [
        {"range": {"price": {"gte": 10.15, "lte": 11}}}
      ]
    }
  }
}




PUT position?pretty
GET _cat/indices?v
GET position1/_mapping?pretty
DELETE .kibana_task_manager_1 
DELETE .kibana_1


POST position1/_doc 
{ "title": "小明", "price":10.2, "description":"b" }

POST position1/_doc 
{ "title": "中华人民共和国", "price":10.9,"description":"dsdsf" }

PUT position1
 {

    "mappings":{

        "properties":{

            "title":{

                "type":"text"

            },

            "description":{

                "type":"text"

            },

            "price":{

                "type":"double"

            },

            "onSale":{

                "type":"boolean"

            },

            "type":{

                "type":"integer"

            },

            "createDate":{

                "type":"date"

            }

        }

    }
}  


A programmer who loves life

143 声望
9 粉丝
0 条评论
推荐阅读
Ubuntu 20.04 搭建 Elasticsearch 7.x 小集群(qbit)
环境ES 节点硬件:3 台 AWS m5.4xlarge(16 vCPU/64GB 内存)Kibana 硬件:1 台 AWS m5.large(2 vCPU/8GB 内存)操作系统:Ubuntu 20.04 LTSElasticsearch 7.9.3Kibana 7.9.3机器示意图操作系统这里主要讲 EBS ...

qbit阅读 4.1k

elasticsearch(2)- DQL 用法
Query DSL:ElasticSearch提供了一个可以执行的JSON风格的DSL(domain-specific language 领域特定语言),这个被称为Query DSL。

KerryWu1阅读 1.1k

Helm3-安装ElasticSearch和Kibana
因为自己的网站要做全文检索功能,本身我是使用mongodb做为数据库的,但是考虑到后期数据量非常大而且用户体验也要跟上,所以准备入手elasticsearch做为我的站内搜索,现分享给大家。

Awbeci阅读 2.2k

es笔记六之聚合操作之指标聚合
本文首发于公众号:Hunter后端原文链接:es笔记六之聚合操作之指标聚合聚合操作,在 es 中的聚合可以分为大概四种聚合:bucketing(桶聚合)mertic(指标聚合)matrix(矩阵聚合)pipeline(管道聚合)bucket类似于分类分...

Hunter2阅读 452

封面图
将 ES 的快照备份到 Windows 共享目录(qbit)
已将 Windows 的 //172.31.19.143/es_snapshot 共享目录挂载到 ES 服务器的 /mnt/winshare 目录

qbit阅读 2k

Linux下安装ElasticSearch+head+kinbana
Elasticsearch是一个基于Lucene的搜索服务器。它提供了一个分布式多用户能力的全文搜索引擎,基于RESTful web接口。Elasticsearch是用Java语言开发的,并作为Apache许可条款下的开放源码发布,是一种流行的企业级...

Zeran阅读 1.8k

Helm3-安装带有ik分词的ElasticSearch
操作步骤:1、下载ik分词包2、制作带有ik分词的docker镜像3、修改bitnami/elasticsearch的values.yaml文件,并使用刚刚制作的docker镜像4、安装elasticsearch和kibana5、在kibana中使用develop tools验证ik是否安...

Awbeci阅读 1.5k

A programmer who loves life

143 声望
9 粉丝
宣传栏