ElasticSearch笔记整理(四):ElasticSearch休息与设置,M

  (toc)

  <人力资源/>   

ElasticSearch休息

  
 <代码> curl xget ' http://uplooking01:9200/银行/_search ? q=*,漂亮的
  
  旋度-XPOST“http://uplooking01:9200/银行/_search吗?很“- d”
  {
  "查询":{
  “match_all”: {}
  }
  }'
  -------------------------------------------------------
  在上面基础至少,只要2条结果:
  旋度xget”http://uplooking01:9200/银行/_search ? q=*, pretty&从=0,大?2”
  
  旋度-XPOST“http://uplooking01:9200/银行/_search吗?很“- d”
  {
  "查询":{
  “match_all”: {}
  },
  来自:0,
  大小:2
  }'
  --------------------------------------------------
  排序
  旋度-XPOST“http://uplooking01:9200/银行/_search吗?很“- d”
  {
  "查询":{
  “match_all”: {}
  },
  来自:0,
  大小:2
  “排序”:{“平衡”:{“秩序”:“desc}}
  }'
  --------------------------------------------------
  执行返回的字段
  旋度xget”http://uplooking01:9200/银行/_search ? _source=年龄,balance& pretty&从=0,大?2”
  
  帖子操作如何获取呢?
  旋度-XPOST“http://uplooking01:9200/银行/_search吗?很“- d”
  {
  "查询":{
  “match_all”: {}
  },
  来自:0,
  大小:2
  “排序”:{“平衡”:{“秩序”:“desc}},
  “_source”:[“平衡”,“时代”)
  }'
  ----------------------------------------------------------
  匹配:具体匹配操作
  旋度-XPOST“http://uplooking01:9200/银行/_search吗?很“- d”
  {
  "查询":{
  “匹配”:{20}“年龄”:
  },
  “从”:0,
  “大小”:2
  “排序”:{“平衡”:{“秩序”:“desc}},
  “_source”:[“平衡”,“时代”)
  }'
  ----------------------------------------------------------
  保龄球
  旋度-XPOST“http://uplooking01:9200/银行/_search吗?很“- d”
  {
  "查询":{
  “bool”:{
  “应该”:(
  {"匹配":{“年龄”:20}},
  {"匹配":{"性别":" F "}}
  ]
  }
  },
  “从”:0,
  “大小”:2
  “排序”:{“平衡”:{“秩序”:“desc}},
  “_source”:[“平衡”,“时代”)
  }'
  
  {
  "查询":{
  “bool”:{
  “应该”:{"匹配":{“年龄”:20}},
  “应该”:{"匹配":{"性别":" F "}}
  }
  },
  “排序”:{“年龄”:{“秩序”:“asc}},
  “_source”:[“平衡”、“年龄”、“性别”)
  }
  以上两种方式都可以
  --------------------------------------------------------------------------
  过滤查询
  旋度-XPOST“http://uplooking01:9200/银行/_search吗?很“- d”
  ”{
  "查询":{
  "过滤":{
  “查询”:{" match_all ": {}},
  “过滤器”:{
  “范围”:{
  “平衡”:{
  “一种”:20000年,
  “lte”: 30000
  }
  }
  }
  }
  }
  }'
  查询收入在20000到30000之间的数据 
  

设置,映射   

设置>   
 <代码>维护索引库默认配置,当然经常用来修改默认配置。
  例如:分片数量,副本数量
  查看:curl xget http://localhost: 9200/bigdata/_settings ?漂亮
  操作不存在的索引:
  旋度-XPUT ' localhost: 9200/bigdata/'
  - d '{"设置":{“number_of_shards”: 3,“number_of_replicas”: 2}}”
  操作已存在的索引:
  旋度-XPUT ' localhost: 9200/bigdata/_settings '
  - d '{“指数”:{“number_of_replicas”: 2}}” 
  

映射   
 <代码>就是对索引库中索引的字段名称及其数据类型进行定义,类似于关系数据库中表
  建立时要定义字段名及其数据类型那样,(和solr中的schme类似)不过的
  映射比数据库灵活很多,它可以动态添加字段。一般不需要要指都定映射
  可以,因为es会自动根据数据格式定义它的类型,如果你需要对某些字段添加特
  殊属性(如:定义使用其它分词器,是否分词,是否存储等),就必须手动添加映射
  
  查询索引库的映射信息
  旋度xget http://localhost: 9200/bigdata dep/_mapping ?漂亮
  映射修改字段相关属性,见备注
  例如:字段类型,使用哪种分词工具
  映射
  注意:下面可以使用indexAnalyzer定义分词器,也可以使用index_analyzer定义分词器 

ElasticSearch笔记整理(四):ElasticSearch休息与设置,M