关于elasticsearch:ElasticSearch-Query-DSL-Demo

33次阅读

共计 1882 个字符,预计需要花费 5 分钟才能阅读完成。

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"}

        }

    }
}  


正文完
 0