ElasticSearch wildcard查询(英文检索)

wildcard查询
允许使用通配符*和来进行查询
*代表0个或多个字符
工代表任意1个字符
GET /ib3/user/ search { “query”: { “wildcard”:{ “name”: *zhao* }}}
GET /ib3/user/ search { “query”: { “wildcard”:{ *name": “Iii”}}}

#wildcard查询允许使用通配符*和?来进行查询
# * 代表0个或多个字符
# ? 代表任意1个字符
GET /lib3/user/_search 
{
  "query": {
    "wildcard":{ "name":"zhao*"}
  }
}

{
  "took" : 1989,
  "timed_out" : false,
  "_shards" : {
    "total" : 5,
    "successful" : 5,
    "skipped" : 0,
    "failed" : 0
  },
  "hits" : {
    "total" : 2,
    "max_score" : 1.0,
    "hits" : [
      {
        "_index" : "lib3",
        "_type" : "user",
        "_id" : "2",
        "_score" : 1.0,
        "_source" : {
          "name" : "zhaoming",
          "address" : "bei jing hai dian qu qing he zhen",
          "age" : 20,
          "birthday" : "1998-10-12",
          "interests" : "xi huan hejiu, duanlian, changge"
        }
      },
      {
        "_index" : "lib3",
        "_type" : "user",
        "_id" : "1",
        "_score" : 1.0,
        "_source" : {
          "name" : "zhaoliu",
          "address" : "hei long jiang sheng tie ling shi",
          "age" : 50,
          "birthday" : "1970-12-12",
          "interests" : "xi buan hejiu, duanlian, lvyou"
        }
      }
    ]
  }
}


GET /lib3/user/_search
{
  "query": {
    "wildcard": { "name": "li?i"}
  }
}

{
  "took" : 1,
  "timed_out" : false,
  "_shards" : {
    "total" : 5,
    "successful" : 5,
    "skipped" : 0,
    "failed" : 0
  },
  "hits" : {
    "total" : 1,
    "max_score" : 1.0,
    "hits" : [
      {
        "_index" : "lib3",
        "_type" : "user",
        "_id" : "3",
        "_score" : 1.0,
        "_source" : {
          "name" : "lisi",
          "address" : "bei jing hai dian qu qing he zhen",
          "age" : 23,
          "birthday" : "1998-10-12",
          "interests" : "xi huan hejiu,duanlian, changge"
        }
      }
    ]
  }
}

你可能感兴趣的:(java,java,后端)