ElasticSearchワイルドカードクエリ(英語の検索)

 ワイルドカードクエリは、
*ワイルドカードの使用を可能にし、クエリに?
* 0文字以上の文字を表し、
任意の1文字に代わって作業を
GET / IB3 /ユーザー/ {検索 「クエリ」:{「ワイルドカード」:{「名前」:*趙を* }}}
GET / IB3 /ユーザー/検索{ "クエリ":{ "ワイルドカード":{*名":"?IIのI「}}}

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

 

298元記事公開 ウォンの賞賛107 ビューに14万+を

おすすめ

転載: blog.csdn.net/ywl470812087/article/details/104931434