Code Monkey home page Code Monkey logo

es's Introduction

es

elasticsearch分词

nishi

Bool 组合查询 Filter 过滤 Must 如果有多个条件,这些条件必须都满足 Should 如果有多个条件,满足一个或多个即可 Must_not 和must相反

过滤出工资是15000 的

GET 51jobs/job/_search
{
  "query": {
    "bool": {
      "must": [
        {
          "match_all": {}
        }
      ],
      "filter": {
        "term": {
          "salary": 15000
        }
      }
    }
  }
}

检索出“salary”是12000或者“title”是“监控”的并且“salary”不能是8000和“10000”

GET 51jobs/job/_search
{
  "query": {
    "bool": {
      "should": [
        {
          "term": {
            "salary": {
              "value": "12000"
            }
          }
        },
        {
          "term": {
            "title": {
              "value": "监控"
            }
          }
        }
      ],
      "must_not": [
        {
          "term": {
            "salary": {
              "value": "10000"
            }
          }
        },
        {
          "term": {
            "salary": {
              "value": "8000"
            }
          }
        }
      ]
    }
  }
}

过滤空值 检索出工资不为空的

GET 51jobs/job/_search
{
  "query": {
    "bool": {
      "filter": {
        "exists": {
          "field": "salary"
        }
      }
    }
  }
}

检索出城市为空的

GET 51jobs/job/_search
{
  "query": {
    "bool": {
      "must_not": [
        {
          "exists":{
            "field": "city" 
          }
        }
      ]
    }
  }
}

es's People

Contributors

lxshen avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.