Domain Specific Language
特定领域语言,基于JSON格式的数据查询,查询更灵活,有利于复杂查询
一、普通url路径参数搜索
  • 数据准备
1.建立名字为 shop 的索引
2.手动建立mappings

POST        http://192.168.2.223:9200/shop/_mapping
{
"properties": {
"id": {
"type": "long"
},
"age": {
"type": "integer"
},
"username": {
"type": "keyword"
},
"nickname": {
"type": "text",
"analyzer": "ik_max_word"
},
"money": {
"type": "float"
},
"desc": {
"type": "text",
"analyzer": "ik_max_word"
},
"sex": {
"type": "byte"
},
"birthday": {
"type": "date"
},
"face": {
"type": "text",
"index": false
}
}
}
3.添加数据

POST   http://192.168.2.223:9200/shop/_doc/1001
{
"id": 1011,
"age": 31,
"username": "sprder",
"nickname": "皮特帕克",
"money": 180.8,
"desc": "它是一个超级英雄",
"sex": 1,
"birthday": "1989-08-14",
"face": "https://www.zhouhong.com/static/img/index/logo.png"
}
{
"id": 1008,
"age": 19,
"username": "zhoujiang",
"nickname": "周江",
"money": 1056.8,
"desc": "周江大学毕业后,进了阿里",
"sex": 1,
"birthday": "1995-06-14",
"face": "https://www.zhouhong.com/static/img/index/logo.png"
}
{
"id": 1007,
"age": 19,
"username": "msgame",
"nickname": "gamexbox",
"money": 1056.8,
"desc": "明天去进货,最近微软处理很多游戏机,还要买xbox游戏卡带",
"sex": 1,
"birthday": "1985-05-14",
"face": "https://www.zhouhong.com/static/img/index/logo.png"
}
{
"id": 1003,
"age": 20,
"username": "bigFace",
"nickname": "飞翔的巨鹰",
"money": 66.8,
"desc": "周江和导游坐飞机去海外旅游,去了新马泰和欧洲",
"sex": 1,
"birthday": "1996-01-14",
"face": "https://www.zhouhong.com/static/img/index/logo.png"
}
{
"id": 1002,
"age": 19,
"username": "zhouhong",
"nickname": "周红",
"money": 77.8,
"desc": "今天上下班都很堵,车流量很大",
"sex": 1,
"birthday": "1993-01-24",
"face": "https://www.zhouhong.com/static/img/index/logo.png"
}
{
"id": 1012,
"age": 31,
"username": "super hero",
"nickname": "super hero",
"money": 188.8,
"desc": "BatMan, GreenArrow, SpiderMan, IronMan... are all Super Hero",
"sex": 1,
"birthday": "1980-08-14",
"face": "https://www.zhouhong.com/static/img/index/logo.png"
}
{
"id": 1010,
"age": 30,
"username": "tata",
"nickname": "隔壁老王",
"money": 100.8,
"desc": "隔壁老外去国外出差,带给我很多好吃的",
"sex": 1,
"birthday": "1988-07-14",
"face": "https://www.zhouhong.com/static/img/index/logo.png"
}
{
"id": 1009,
"age": 22,
"username": "shaonian",
"nickname": "骚年轮",
"money": 96.8,
"desc": "骚年在大学毕业后,考研究生去了",
"sex": 1,
"birthday": "1998-07-14",
"face": "https://www.zhouhong.com/static/img/index/logo.png"
}
{
"id": 1006,
"age": 19,
"username": "zhouhong",
"nickname": "我叫周红",
"money": 156.8,
"desc": "我叫周红,今年20岁,是一名毕业生,我在琦䯲星球做演讲",
"sex": 1,
"birthday": "1993-04-14",
"face": "https://www.zhouhong.com/static/img/index/logo.png"
}
{
"id": 1005,
"age": 25,
"username": "gotoplay",
"nickname": "ps游戏机",
"money": 155.8,
"desc": "今年生日,女友送了我一台play station游戏机,非常好玩,非常不错",
"sex": 1,
"birthday": "1989-03-14",
"face": "https://www.zhouhong.com/static/img/index/logo.png"
}
{
"id": 1004,
"age": 22,
"username": "flyfish",
"nickname": "水中鱼",
"money": 55.8,
"desc": "昨天周红在学校的池塘里,看到有很多鱼在游泳",
"sex": 0,
"birthday": "1988-02-14",
"face": "https://www.zhouhong.com/static/img/index/logo.png"
}
{
"id": 1001,
"age": 18,
"username": "zhoujiang",
"nickname": "周江",
"money": 88.8,
"desc": "周江在大学学习java和前端",
"sex": 0,
"birthday": "1992-12-24",
"face": "https://www.zhouhong.com/static/img/index/logo.png"
}
二、检索:
普通检索:
  • http://192.168.2.223:9200/shop/_search?q=desc:周红&q=age:20
  • {
    "took": 8,
    "timed_out": false,
    "_shards": {
    "total": 3,
    "successful": 3,
    "skipped": 0,
    "failed": 0
    },
    "hits": {
    "total": {
    "value": 1,
    "relation": "eq"
    },
    "max_score": 1,
    "hits": [
    {
    "_index": "shop",
    "_type": "_doc",
    "_id": "1003",
    "_score": 1,
    "_source": {
    "id": 1003,
    "age": 20,
    "username": "bigFace",
    "nickname": "飞翔的巨鹰",
    "money": 66.8,
    "desc": "周江和导游坐飞机去海外旅游,去了新马泰和欧洲",
    "sex": 1,
    "birthday": "1996-01-14",
    "face": "https://www.zhouhong.com/static/img/index/logo.png"
    }
    }
    ]
    }
    }
DSL检索:
  • match_phrase 查询同一个字段中几个词,可以跳过其他词,slop表示可以跳过的最大词数
    • POST http://192.168.2.223:9200/shop/_doc/_search operator 为 “or”表示:字段只要有一个分词就可以查出来,operator 为 “and”表示:字段必须包含分词分出来的所有字段。
    • {
      "query": {
      "match": {
      "desc": {
      "query": "周红",
      "operator": "and"
      }
      }
      },
      "_source": ["id","username","age"]
      }
    • POST http://192.168.2.223:9200/shop/_doc/_search
    • ​minimum_should_match: 最低匹配精度,至少有[分词后的词语个数]x百分百,得出一个数据值取整。举个例子:当前属性设置为70,若一个用户查询检索内容分词后有10个词语,那么匹配度按照 10x70%=7,则desc中至少需要有7个词语匹配,就展示;若分词后有8个,则 8x70%=5.6,则desc中至少需要有5个词语匹配,就展示。
    • minimum_should_match 也能设置具体的数字,表示拆分出来的词在一个字段中个数
    • {
      "query": {
      "match": {
      "desc": {
      "query": "女友生日送我好玩的xbox游戏机",
      "minimum_should_match": "60%"
      }
      }
      }
      }
  • multi_match 对多个字段进行检索
    • POST http://192.168.2.223:9200/shop/_doc/_search ^10 表示权重,权重,为某个字段设置权重,权重越高,文档相关性得分就越高。通畅来说搜索商品名称要比商品简介的权重更高。
    • {
      "query": {
      "multi_match": {
      "query": "游戏",
      "fields": [
      "desc^10","nickname"
      ]
      }
      }
      }
  • bool 查询
    • POST http://192.168.2.223:9200/shop/_doc/_search
    • must :多个条件全部要满足, should:或者的意思,满足一个条件即可,must_not :除了满足所有条件剩下的数据。
    • {
      "query": {
      "bool": {
      "must": [
      {
      "multi_match": {
      "query": "游戏",
      "fields": ["desc","nickname"]
      }
      },
      {
      "term": {
      "age": "19"
      }
      }
      ]
      }
      }
      }
  • post_filter 过滤器
    • POST http://192.168.2.223:9200/shop/_doc/_search
    • 对搜索出来的结果进行数据过滤。不会到es库里去搜,不会去计算文档的相关度分数,所以过滤的性能会比较高,过滤器可以和全文搜索结合在一起使用。
post_filter元素是一个顶层元素,只会对搜索结果进行过滤。不会计算数据的匹配度相关性分数,不会根据分数去排序,query则相反,会计算分数,也会按照分数去排序。
使用场景:
  • ​query:根据用户搜索条件检索匹配记录
  • post_filter:用于查询后,对结果数据的筛选
实操:查询账户金额大于80元,小于等于155.8元的用户
gte:大于等于
lte:小于等于
gt:大于
lt:小于
{
"query": {
"match": {
"sex": "1"
}
},
"post_filter": {
"range": {
"money": {
"gte": 60,
"lte": 155.8
}
}
}
}
  • sort 排序功能
    • POST http://192.168.2.223:9200/shop/_doc/_search 先以money排序再以age排序,注意:只能对整形排序,不能对文本类型排序。
    • {
      "query": {
      "match": {
      "sex": "1"
      }
      },
      "sort": [
      {
      "money": "asc"
      },
      {
      "age": "asc"
      }
      ]
      }
    • 对文本排序
    • 需要对排序字段加一个附加属性,类型选择为keyword
    • 1.创建索引
      POST /shop2/_mapping
      {
      "properties": {
      "id": {
      "type": "long"
      },
      "nickname": {
      "type": "text",
      "analyzer": "ik_max_word",
      "fields": {
      "keyword": {
      "type": "keyword"
      }
      }
      }
      }
      }

      2.插入数据
      POST /shop2/_doc
      {
      "id": 1001,
      "nickname": "美丽的风景"
      }
      {
      "id": 1002,
      "nickname": "漂亮的小哥哥"
      }
      {
      "id": 1003,
      "nickname": "飞翔的巨鹰"
      }
      {
      "id": 1004,
      "nickname": "完美的天空"
      }
      {
      "id": 1005,
      "nickname": "广阔的海域"
      }
      3.排序     POST    http://192.168.2.223:9200/shop2/_doc/_search
      {
      "sort": [
      {
      "nickname.keyword": "desc"
      }
      ]
      }
  • highlight 关键字高亮显示
    • POST http://192.168.2.223:9200/shop/_doc/_search
    • {
      "query": {
      "match": {
      "desc": "周红"
      }
      },
      "highlight": {
      "pre_tags": ["<span>"],
      "post_tags": ["</span>"],
      "fields": {
      "desc": {}
      }
      }
      }
      结果:默认为em标签,上面设置为自定义的<span>标签,对页面 em/span 标签做一个颜色设置就可以实现高亮显示了。
    • {
      "took": 110,
      "timed_out": false,
      "_shards": {
      "total": 3,
      "successful": 3,
      "skipped": 0,
      "failed": 0
      },
      "hits": {
      "total": {
      "value": 2,
      "relation": "eq"
      },
      "max_score": 1.1329247,
      "hits": [
      {
      "_index": "shop",
      "_type": "_doc",
      "_id": "1004",
      "_score": 1.1329247,
      "_source": {
      "id": 1004,
      "age": 22,
      "username": "flyfish",
      "nickname": "水中鱼",
      "money": 55.8,
      "desc": "昨天周红在学校的池塘里,看到有很多鱼在游泳",
      "sex": 0,
      "birthday": "1988-02-14",
      "face": "https://www.zhouhong.com/static/img/index/logo.png"
      },
      "highlight": {
      "desc": [
      "昨天<em>周红</em>在学校的池塘里,看到有很多鱼在游泳"
      ]
      }
      },
      {
      "_index": "shop",
      "_type": "_doc",
      "_id": "1006",
      "_score": 0.9585575,
      "_source": {
      "id": 1006,
      "age": 19,
      "username": "zhouhong",
      "nickname": "我叫周红",
      "money": 156.8,
      "desc": "我叫周红,今年20岁,是一名毕业生,我在琦䯲星球做演讲",
      "sex": 1,
      "birthday": "1993-04-14",
      "face": "https://www.zhouhong.com/static/img/index/logo.png"
      },
      "highlight": {
      "desc": [
      "我叫<em>周红</em>,今年20岁,是一名毕业生,我在琦䯲星球做演讲"
      ]
      }
      }
      ]
      }
Domain Specific Language
特定领域语言,基于JSON格式的数据查询,查询更灵活,有利于复杂查询
一、普通url路径参数搜索
  • 数据准备
1.建立名字为 shop 的索引
2.手动建立mappings
POST http://192.168.2.223:9200/shop/_mapping
{
"properties": {
"id": {
"type": "long"
},
"age": {
"type": "integer"
},
"username": {
"type": "keyword"
},
"nickname": {
"type": "text",
"analyzer": "ik_max_word"
},
"money": {
"type": "float"
},
"desc": {
"type": "text",
"analyzer": "ik_max_word"
},
"sex": {
"type": "byte"
},
"birthday": {
"type": "date"
},
"face": {
"type": "text",
"index": false
}
}
}

3.添加数据
POST http://192.168.2.223:9200/shop/_doc/1001
{
"id": 1011,
"age": 31,
"username": "sprder",
"nickname": "皮特帕克",
"money": 180.8,
"desc": "它是一个超级英雄",
"sex": 1,
"birthday": "1989-08-14",
"face": "https://www.zhouhong.com/static/img/index/logo.png"
}
{
"id": 1008,
"age": 19,
"username": "zhoujiang",
"nickname": "周江",
"money": 1056.8,
"desc": "周江大学毕业后,进了阿里",
"sex": 1,
"birthday": "1995-06-14",
"face": "https://www.zhouhong.com/static/img/index/logo.png"
}
{
"id": 1007,
"age": 19,
"username": "msgame",
"nickname": "gamexbox",
"money": 1056.8,
"desc": "明天去进货,最近微软处理很多游戏机,还要买xbox游戏卡带",
"sex": 1,
"birthday": "1985-05-14",
"face": "https://www.zhouhong.com/static/img/index/logo.png"
}
{
"id": 1003,
"age": 20,
"username": "bigFace",
"nickname": "飞翔的巨鹰",
"money": 66.8,
"desc": "周江和导游坐飞机去海外旅游,去了新马泰和欧洲",
"sex": 1,
"birthday": "1996-01-14",
"face": "https://www.zhouhong.com/static/img/index/logo.png"
}
{
"id": 1002,
"age": 19,
"username": "zhouhong",
"nickname": "周红",
"money": 77.8,
"desc": "今天上下班都很堵,车流量很大",
"sex": 1,
"birthday": "1993-01-24",
"face": "https://www.zhouhong.com/static/img/index/logo.png"
}
{
"id": 1012,
"age": 31,
"username": "super hero",
"nickname": "super hero",
"money": 188.8,
"desc": "BatMan, GreenArrow, SpiderMan, IronMan... are all Super Hero",
"sex": 1,
"birthday": "1980-08-14",
"face": "https://www.zhouhong.com/static/img/index/logo.png"
}
{
"id": 1010,
"age": 30,
"username": "tata",
"nickname": "隔壁老王",
"money": 100.8,
"desc": "隔壁老外去国外出差,带给我很多好吃的",
"sex": 1,
"birthday": "1988-07-14",
"face": "https://www.zhouhong.com/static/img/index/logo.png"
}
{
"id": 1009,
"age": 22,
"username": "shaonian",
"nickname": "骚年轮",
"money": 96.8,
"desc": "骚年在大学毕业后,考研究生去了",
"sex": 1,
"birthday": "1998-07-14",
"face": "https://www.zhouhong.com/static/img/index/logo.png"
}
{
"id": 1006,
"age": 19,
"username": "zhouhong",
"nickname": "我叫周红",
"money": 156.8,
"desc": "我叫周红,今年20岁,是一名毕业生,我在琦䯲星球做演讲",
"sex": 1,
"birthday": "1993-04-14",
"face": "https://www.zhouhong.com/static/img/index/logo.png"
}
{
"id": 1005,
"age": 25,
"username": "gotoplay",
"nickname": "ps游戏机",
"money": 155.8,
"desc": "今年生日,女友送了我一台play station游戏机,非常好玩,非常不错",
"sex": 1,
"birthday": "1989-03-14",
"face": "https://www.zhouhong.com/static/img/index/logo.png"
}
{
"id": 1004,
"age": 22,
"username": "flyfish",
"nickname": "水中鱼",
"money": 55.8,
"desc": "昨天周红在学校的池塘里,看到有很多鱼在游泳",
"sex": 0,
"birthday": "1988-02-14",
"face": "https://www.zhouhong.com/static/img/index/logo.png"
}
{
"id": 1001,
"age": 18,
"username": "zhoujiang",
"nickname": "周江",
"money": 88.8,
"desc": "周江在大学学习java和前端",
"sex": 0,
"birthday": "1992-12-24",
"face": "https://www.zhouhong.com/static/img/index/logo.png"
}
二、检索:
  • http://192.168.2.223:9200/shop/_search?q=desc:周红&q=age:20
{
"took": 8,
"timed_out": false,
"_shards": {
"total": 3,
"successful": 3,
"skipped": 0,
"failed": 0
},
"hits": {
"total": {
"value": 1,
"relation": "eq"
},
"max_score": 1,
"hits": [
{
"_index": "shop",
"_type": "_doc",
"_id": "1003",
"_score": 1,
"_source": {
"id": 1003,
"age": 20,
"username": "bigFace",
"nickname": "飞翔的巨鹰",
"money": 66.8,
"desc": "周江和导游坐飞机去海外旅游,去了新马泰和欧洲",
"sex": 1,
"birthday": "1996-01-14",
"face": "https://www.zhouhong.com/static/img/index/logo.png"
}
}
]
}
}
 
二、DSL搜索
{
"query": {
"match_all": {}
}
}
{
"query": {
"match_all": {}
},
"_source": ["id","username","age"]
}
{
"query": {
"match_all": {}
},
"_source": ["id","username","age"],
"from": 0,
"size": 5
}
{
"query": {
"match_phrase": {
"desc": {
"query": "今天 车流量",
"slop": 100
}
}
}
}
{
"query": {
"term": {
"desc": "学习"
}
}
}
  • terms 对个关键字查询
{
"query": {
"terms": {
"desc": ["学习","周红","周江"]
}
}
}
{
"query": {
"match": {
"desc": "周红"
}
},
"_source": ["id","username","age"]
}
{
"query": {
"match": {
"desc": {
"query": "周红",
"operator": "and"
}
}
},
"_source": ["id","username","age"]
}
    • POST http://192.168.2.223:9200/shop/_doc/_search
    • ​minimum_should_match: 最低匹配精度,至少有[分词后的词语个数]x百分百,得出一个数据值取整。举个例子:当前属性设置为70,若一个用户查询检索内容分词后有10个词语,那么匹配度按照 10x70%=7,则desc中至少需要有7个词语匹配,就展示;若分词后有8个,则 8x70%=5.6,则desc中至少需要有5个词语匹配,就展示。
    • minimum_should_match 也能设置具体的数字,表示拆分出来的词在一个字段中个数
{
"query": {
"match": {
"desc": {
"query": "女友生日送我好玩的xbox游戏机",
"minimum_should_match": "60%"
}
}
}
}
{
"query": {
"ids": {
"type": "_doc",
"values": ["1001","1005","1006"]
}
},
"_source": ["id","username","desc"]
}
  • multi_match 对多个字段进行检索
    • POST http://192.168.2.223:9200/shop/_doc/_search ^10 表示权重,权重,为某个字段设置权重,权重越高,文档相关性得分就越高。通畅来说搜索商品名称要比商品简介的权重更高。
{
"query": {
"multi_match": {
"query": "游戏",
"fields": [
"desc^10","nickname"
]
}
}
}
{
"query": {
"bool": {
"must": [
{
"multi_match": {
"query": "游戏",
"fields": ["desc","nickname"]
}
},
{
"term": {
"age": "19"
}
}
]
}
}
}
 
  • post_filter 过滤器
    • POST http://192.168.2.223:9200/shop/_doc/_search
    • 对搜索出来的结果进行数据过滤。不会到es库里去搜,不会去计算文档的相关度分数,所以过滤的性能会比较高,过滤器可以和全文搜索结合在一起使用。
post_filter元素是一个顶层元素,只会对搜索结果进行过滤。不会计算数据的匹配度相关性分数,不会根据分数去排序,query则相反,会计算分数,也会按照分数去排序。
使用场景:
  • ​query:根据用户搜索条件检索匹配记录
  • post_filter:用于查询后,对结果数据的筛选
实操:查询账户金额大于80元,小于等于155.8元的用户
gte:大于等于
lte:小于等于
gt:大于
lt:小于
{
"query": {
"match": {
"sex": "1"
}
},
"post_filter": {
"range": {
"money": {
"gte": 60,
"lte": 155.8
}
}
}
}
 
{
"query": {
"match": {
"sex": "1"
}
},
"sort": [
{
"money": "asc"
},
{
"age": "asc"
}
]
}
    • 对文本排序
    • 需要对排序字段加一个附加属性,类型选择为keyword
1.创建索引
POST /shop2/_mapping
{
"properties": {
"id": {
"type": "long"
},
"nickname": {
"type": "text",
"analyzer": "ik_max_word",
"fields": {
"keyword": {
"type": "keyword"
}
}
}
}
}
 
2.插入数据
POST /shop2/_doc
{
"id": 1001,
"nickname": "美丽的风景"
}
{
"id": 1002,
"nickname": "漂亮的小哥哥"
}
{
"id": 1003,
"nickname": "飞翔的巨鹰"
}
{
"id": 1004,
"nickname": "完美的天空"
}
{
"id": 1005,
"nickname": "广阔的海域"
}

 
3.排序 POST http://192.168.2.223:9200/shop2/_doc/_search
{
"sort": [
{
"nickname.keyword": "desc"
}
]
}

{
"query": {
"exists": {
"field": "desc"
}
}
}
 
{
"query": {
"match": {
"desc": "周红"
}
},
"highlight": {
"pre_tags": ["<span>"],
"post_tags": ["</span>"],
"fields": {
"desc": {}
}
}
}
结果:默认为em标签,上面设置为自定义的<span>标签,对页面 em/span 标签做一个颜色设置就可以实现高亮显示了。
{
"took": 110,
"timed_out": false,
"_shards": {
"total": 3,
"successful": 3,
"skipped": 0,
"failed": 0
},
"hits": {
"total": {
"value": 2,
"relation": "eq"
},
"max_score": 1.1329247,
"hits": [
{
"_index": "shop",
"_type": "_doc",
"_id": "1004",
"_score": 1.1329247,
"_source": {
"id": 1004,
"age": 22,
"username": "flyfish",
"nickname": "水中鱼",
"money": 55.8,
"desc": "昨天周红在学校的池塘里,看到有很多鱼在游泳",
"sex": 0,
"birthday": "1988-02-14",
"face": "https://www.zhouhong.com/static/img/index/logo.png"
},
"highlight": {
"desc": [
"昨天<em>周红</em>在学校的池塘里,看到有很多鱼在游泳"
]
}
},
{
"_index": "shop",
"_type": "_doc",
"_id": "1006",
"_score": 0.9585575,
"_source": {
"id": 1006,
"age": 19,
"username": "zhouhong",
"nickname": "我叫周红",
"money": 156.8,
"desc": "我叫周红,今年20岁,是一名毕业生,我在琦䯲星球做演讲",
"sex": 1,
"birthday": "1993-04-14",
"face": "https://www.zhouhong.com/static/img/index/logo.png"
},
"highlight": {
"desc": [
"我叫<em>周红</em>,今年20岁,是一名毕业生,我在琦䯲星球做演讲"
]
}
}
]
}
}
 

Elasticsearch---DSL搜索实践的更多相关文章

  1. ElasticSearch位置搜索

    ElasticSearch位置搜索 学习了:https://blog.csdn.net/bingduanlbd/article/details/52253542 学习了:https://blog.cs ...

  2. ElasticSearch入门-搜索(java api)

    ElasticSearch入门-搜索(java api) package com.qlyd.searchhelper; import java.util.Map; import net.sf.json ...

  3. PHP使用ElasticSearch做搜索

    PHP 使用 ElasticSearch 做搜索 https://blog.csdn.net/zhanghao143lina/article/details/80280321 https://www. ...

  4. 十九种Elasticsearch字符串搜索方式终极介绍

    前言 刚开始接触Elasticsearch的时候被Elasticsearch的搜索功能搞得晕头转向,每次想在Kibana里面查询某个字段的时候,查出来的结果经常不是自己想要的,然而又不知道问题出在了哪 ...

  5. 【Elasticsearch学习】DSL搜索大全(持续更新中)

    1.复合查询 复合查询能够组合其他复合查询或者查询子句,同时也可以组合各个查询的查询结果及得分,也可以从Query查询转换为Filter过滤器查询. 首先介绍一下Query Context和 Filt ...

  6. Elasticsearch 教程--搜索

    搜索 – 基本工具 到目前为止,我们已经学习了Elasticsearch的分布式NOSQL文档存储,我们可以直接把JSON文档扔到Elasticsearch中,然后直接通过ID来进行调取.但是Elas ...

  7. Elasticsearch 数据搜索篇&#183;【入门级干货】

    ES即简单又复杂,你可以快速的实现全文检索,又需要了解复杂的REST API.本篇就通过一些简单的搜索命令,帮助你理解ES的相关应用.虽然不能让你理解ES的原理设计,但是可以帮助你理解ES,探寻更多的 ...

  8. Elasticsearch DSL中Query与Filter的不同

    Elasticsearch支持很多查询方式,其中一种就是DSL,它是把请求写在JSON里面,然后进行相关的查询. 举个DSL例子 GET _search { "query": { ...

  9. Elasticsearch深入搜索之结构化搜索及JavaAPI的使用

    一.Es中创建索引 1.创建索引: 在之前的Es插件的安装和使用中说到创建索引自定义分词器和创建type,当时是分开写的,其实创建索引时也可以创建type,并指定分词器. PUT /my_index ...

  10. Elasticsearch 数据搜索篇&#183;【入门级干货】===转

    ES即简单又复杂,你可以快速的实现全文检索,又需要了解复杂的REST API.本篇就通过一些简单的搜索命令,帮助你理解ES的相关应用.虽然不能让你理解ES的原理设计,但是可以帮助你理解ES,探寻更多的 ...

随机推荐

  1. 用python来个百度关键词刷排名脚本

    目的:写个脚本来提升百度排名 我一个seo届前辈的朋友找我,他说,seo事无巨细,自己主观方面能做的几乎都能做了,提升百度等搜索引擎中的排名往往效果不佳或者起效周期慢.能不能人为去干预下呢? 获得排名 ...

  2. linux下安装oracle

    一>1.关闭防火墙,禁用selinux vi /etc/selinux/config  修改SELINUX=disabled,然后重启,如果不想重启使用命令setenforce 0 2.安装依赖 ...

  3. 【POJ 1094】拓扑排序

    题意 给出n,代表有以A开始的n个字母,给出它们的m个小于关系(A<B).如果前i个关系可以确定n个字母的一个顺序就输出: Sorted sequence determined after i ...

  4. SQL2008 强烈要求限制最大内存

    64位开了AWE没什么潜在问题,另外最大内存设置强烈要求改掉,不要用默认的,一般留2~3G内存给操作系统.你是怎么看到20多G是被awe用了的? 如果内存大的话,只留1GB给OS会有问题,可以参考下面 ...

  5. LintCode ---- 刷题总结

    对于一个给定的 source 字符串和一个 target 字符串,你应该在 source 字符串中找出 target 字符串出现的第一个位置(从0开始).如果不存在,则返回 -1. 基本:两重for循 ...

  6. 容器在 Weave 中如何通信和隔离?- 每天5分钟玩转 Docker 容器技术(65)

    上一节我们分析了 Weave 的网络结构,今天讨论 Weave 的连通和隔离特性. 首先在host2 执行如下命令: weave launch 192.168.56.104 这里必须指定 host1 ...

  7. Centos下Sphinx中文分词编译安装测试---CoreSeek

    要支持中文分词,还需要下载Coreseek,可以去官方搜索下载,这里我用的4.1 百度云下载地址:      https://pan.baidu.com/s/1slNIyHf tar -zxvf co ...

  8. angularJS的插件使用

    $uibModal&&$uibModalInstance $uibModal和$uibModalInstance是一款angularJS的弹窗控件,github地址 http://an ...

  9. Niop2017初赛滚粗记

    初赛踢蹬滚粗 TOT (╯°Д°)╯︵┻━┻ ヽ(`Д´)ノ︵ ┻━┻ ┻━┻ 排序啊排序,净是排序,自打我学了C++就再没学过排序!!wtf! (╯°Д°)╯︵ /(.□ . )我tm怎么知道建国那 ...

  10. 什么是真正的Java技术,本篇文章让你了解

    “你学习一门技术的最佳时机是三年前,其次是现在.”这句话对于哪一种行业都很适用,如果你已经学习过Java,那么恭喜你你很有先见之明,如果你并不了解Java,这篇文章带你快速掌握Java的几个核心知识点 ...