摘要: //冒泡排序 public static void sort1(int[] arr){ for (int i=0;iarr[j]){ int tmp = arr[i]; arr[i] = arr[j]; arr[j] = tmp; } } } }... 阅读全文
posted @ 2019-07-17 18:12 努力挣扎的小兵 阅读(532) 评论(0) 推荐(0)
摘要: //需要时加锁,双重校验 class CustomSingleton{ private static CustomSingleton customSingleton = null; private CustomSingleton(){}; public static CustomSingleton getCustomSingleton(){ if(custom... 阅读全文
posted @ 2019-07-17 17:11 努力挣扎的小兵 阅读(167) 评论(0) 推荐(0)
摘要: public class TestCglibProxy { public static void main(String[] args) { UserService userService = new UserServiceImpl(); CglibProxy cglibProxy = new CglibProxy(); Enha... 阅读全文
posted @ 2019-07-17 17:04 努力挣扎的小兵 阅读(135) 评论(0) 推荐(0)
摘要: public class TestJdkProxy { public static void main(String[] args) { UserService userService = new UserServiceImpl(); JdkProxy jdkProxy = new JdkProxy(userService); Us... 阅读全文
posted @ 2019-07-17 17:02 努力挣扎的小兵 阅读(129) 评论(0) 推荐(0)
摘要: 回文:aba abcba 双重循环遍历字符串,外层从第一个开始找,内层循环从最后一个开始找。当外层的字符和内存循环的字符相等时则组成新的数组,判断是否是回文 阅读全文
posted @ 2019-07-17 16:34 努力挣扎的小兵 阅读(285) 评论(0) 推荐(0)
摘要: 1.注册一个新的license,每一项都要填写,每次可以使用一年,一年到期后再来注册一个新的 2.更新license (官方文档:https://www.elastic.co/guide/en/x-pack/5.6/installing-license.html)上传license文件后执行下面的命 阅读全文
posted @ 2019-07-17 12:23 努力挣扎的小兵 阅读(1712) 评论(0) 推荐(0)
摘要: 当索引一个文档的时候,文档会被存储到一个主分片中。 Elasticsearch 如何知道一个文档应该存放到哪个分片中呢?当我们创建文档时,它如何决定这个文档应当被存储在分片 1 还是分片 2 中呢?首先这肯定不会是随机的,否则将来要获取文档的时候我们就不知道从何处寻找了。实际上,这个过程是根据下面这 阅读全文
posted @ 2019-07-17 12:20 努力挣扎的小兵 阅读(1708) 评论(0) 推荐(0)
摘要: 1.Cluster(集群)# 集群名称标识了你的集群,自动探查会用到它。默认值为elasticsearch# 如果你在同一个网络中运行多个集群,那就要确保你的集群名称是独一无二的。## cluster.name: my-application 2.Node(节点)# 节点名称会在启动的时候自动生成, 阅读全文
posted @ 2019-07-17 12:16 努力挣扎的小兵 阅读(658) 评论(0) 推荐(0)
摘要: https://www.elastic.co/guide/cn/elasticsearch/guide/current/mapping.html如果有两个不同的类型,每个类型都有同名的字段,但映射不同(例如:一个是字符串一个是数字),将会出现什么情况?简单回答是,Elasticsearch 不会允许 阅读全文
posted @ 2019-07-17 12:16 努力挣扎的小兵 阅读(8789) 评论(0) 推荐(0)
摘要: discovery.zen.minimum_master_nodes: 2这个参数决定了要选举一个Master需要多少个主节点(最少候选主节点数)。默认值是1。官方给出的建议是 N/2 + 1,N是集群中主节点的数量,例如一个有3个主节点的集群,minimum_master_nodes 应该被设置成 阅读全文
posted @ 2019-07-17 12:15 努力挣扎的小兵 阅读(397) 评论(0) 推荐(0)
摘要: https://www.elastic.co/guide/cn/elasticsearch/guide/current/dynamic-mapping.html#dynamic-mapping当 Elasticsearch 遇到文档中以前 未遇到的字段,它用 dynamic mapping 来确定字 阅读全文
posted @ 2019-07-17 12:14 努力挣扎的小兵 阅读(1068) 评论(0) 推荐(0)
摘要: 查看所有索引的配置信息GET /_settings 查看某个索引的配置信息 创建索引时设置 设置索引的副本信息(分片个数不允许修改) index.mapping.total_fields.limit:索引中的最大字段数。默认值为1000。index.mapping.nested_fields.lim 阅读全文
posted @ 2019-07-17 12:12 努力挣扎的小兵 阅读(3551) 评论(0) 推荐(0)
摘要: 1. 查看ES集群健康状态 查看指定索引库的健康状态http://localhost:9200/_cluster/health/index_name?prettyhttp://localhost:9200/_cluster/health/index_name,index_name2?pretty 阅读全文
posted @ 2019-07-17 12:11 努力挣扎的小兵 阅读(21768) 评论(0) 推荐(0)
摘要: 1.单条所以插入//第一个参数:索引名;第二个参数:索引类型;第三个参数:索引ID(相同的id时修改数据,默认为随机字符串)IndexResponse indexResponse = client.prepareIndex("twitter", "json","1").setSource(json) 阅读全文
posted @ 2019-07-17 12:10 努力挣扎的小兵 阅读(2713) 评论(0) 推荐(0)
摘要: 索引别名API允许使用一个名字来作为一个索引的别名,所有API会自动将别名转换为实际的索引名称。 别名也可以映射到多个索引,别名不能与索引具有相同的名称。别名可以用来做索引迁移和多个索引的查询统一,还可以用来实现视图的功能 查看所有别名GET /_aliases 查看某个别名下的索引GET /_al 阅读全文
posted @ 2019-07-17 12:09 努力挣扎的小兵 阅读(3926) 评论(0) 推荐(0)
摘要: 使用sql插件执行如下语句的时候报错http://10.127.0.1:9200/_sql?sql=select * from test limit 1000000 错误信息:{"error":{"root_cause":[{"type":"query_phase_execution_excepti 阅读全文
posted @ 2019-07-17 11:41 努力挣扎的小兵 阅读(4621) 评论(0) 推荐(0)
摘要: 检查bootstrap.memory_lock设置是否生效 如果您看到mlockall为false,则表示mlockall请求失败。您还将在日志中看到一行"Unable to lock JVM Memory"。在Linux / Unix系统上最可能的原因是运行Elasticsearch的用户没有锁定 阅读全文
posted @ 2019-07-17 11:39 努力挣扎的小兵 阅读(2212) 评论(0) 推荐(0)
摘要: 原因:报了一大串错误,大家不必惊慌,其实只是一个警告,主要是因为你Linux版本过低造成的。 解决方案:1、重新安装新版本的Linux系统2、警告不影响使用,可以忽略 ERROR: bootstrap checks failedmax file descriptors [65535] for ela 阅读全文
posted @ 2019-07-17 11:37 努力挣扎的小兵 阅读(549) 评论(0) 推荐(0)
摘要: 编辑bin/elasticsearch 可以看到elasticsearch使用环境变量JAVA_HOME中配置的jdk:if [ -x "$JAVA_HOME/bin/java" ]; then JAVA="$JAVA_HOME/bin/java"else JAVA=`which java`fi 直 阅读全文
posted @ 2019-07-17 11:26 努力挣扎的小兵 阅读(6401) 评论(0) 推荐(0)
摘要: https://www.elastic.co/guide/cn/elasticsearch/guide/current/custom-dynamic-mapping.html如果你想在运行时增加新的字段,你可能会启用动态映射。 然而,有时候,动态映射 规则 可能不太智能。幸运的是,我们可以通过设置去 阅读全文
posted @ 2019-07-17 11:25 努力挣扎的小兵 阅读(1642) 评论(1) 推荐(0)
摘要: 在轻量搜索中,我们介绍了 _all 字段:一个把其它字段值 当作一个大字符串来索引的特殊字段。 query_string 查询子句(搜索 ?q=john )在没有指定字段时默认使用 _all 字段。_all 字段在新应用的探索阶段,当你还不清楚文档的最终结构时是比较有用的。你可以使用这个字段来做任何 阅读全文
posted @ 2019-07-17 11:24 努力挣扎的小兵 阅读(2638) 评论(0) 推荐(0)
摘要: 默认地,Elasticsearch 在 _source 字段存储代表文档体的JSON字符串。和所有被存储的字段一样, _source 字段在被写入磁盘之前先会被压缩。这个字段的存储几乎总是我们想要的,因为它意味着下面的这些:搜索结果包括了整个可用的文档——不需要额外的从另一个的数据仓库来取文档。如果 阅读全文
posted @ 2019-07-17 11:22 努力挣扎的小兵 阅读(5329) 评论(0) 推荐(0)
摘要: 创建只有 一个主分片,没有副本的小索引: 可以用 update-index-settings API 动态修改副本数: 阅读全文
posted @ 2019-07-17 11:21 努力挣扎的小兵 阅读(5982) 评论(0) 推荐(0)
摘要: 内部对象 经常用于 嵌入一个实体或对象到其它对象中。例如,与其在 tweet 文档中包含 user_name 和 user_id 域,我们也可以这样写: Elasticsearch 会动态 监测新的对象域并映射它们为 对象 ,在 properties 属性下列出内部域: user 和 name 域的 阅读全文
posted @ 2019-07-17 11:20 努力挣扎的小兵 阅读(1036) 评论(0) 推荐(0)
摘要: https://www.elastic.co/guide/cn/elasticsearch/guide/current/mapping-intro.html通过 /_mapping ,我们可以查看 Elasticsearch 在一个或多个索引中的一个或多个类型的映射 。 自定义域映射尽管在很多情况下 阅读全文
posted @ 2019-07-17 11:19 努力挣扎的小兵 阅读(842) 评论(0) 推荐(0)
摘要: https://www.elastic.co/guide/cn/elasticsearch/guide/current/bulk.htmlbulk API 允许在单个步骤中进行多次 create 、 index 、 update 或 delete 请求。bulk 与其他的请求体格式稍有不同,如下所示 阅读全文
posted @ 2019-07-17 11:17 努力挣扎的小兵 阅读(666) 评论(0) 推荐(0)
摘要: https://www.elastic.co/guide/cn/elasticsearch/guide/current/partial-updates.htmlupdate 请求最简单的一种形式是接收文档的一部分作为 doc 的参数, 它只是与现有的文档进行合并。对象被合并到一起,覆盖现有的字段,增 阅读全文
posted @ 2019-07-17 11:16 努力挣扎的小兵 阅读(5309) 评论(0) 推荐(0)
摘要: https://www.elastic.co/guide/cn/elasticsearch/guide/current/create-doc.html当我们索引一个文档, 怎么确认我们正在创建一个完全新的文档,而不是覆盖现有的呢?请记住, _index 、 _type 和 _id 的组合可以唯一标识 阅读全文
posted @ 2019-07-17 11:15 努力挣扎的小兵 阅读(750) 评论(0) 推荐(0)
摘要: https://www.elastic.co/guide/cn/elasticsearch/guide/current/optimistic-concurrency-control.html当我们之前讨论 index , GET 和 delete 请求时,我们指出每个文档都有一个 _version 阅读全文
posted @ 2019-07-17 11:13 努力挣扎的小兵 阅读(1218) 评论(0) 推荐(0)
摘要: github官方参考地址:https://github.com/NLPchina/elasticsearch-sql/ 采用 git + node 的方式,所以安装前需要先安装好node,node npm,node grunt,git 1. 下载:es-sql-site-standalone.zip 阅读全文
posted @ 2019-07-17 11:11 努力挣扎的小兵 阅读(1126) 评论(0) 推荐(0)
摘要: 官方参考地址:https://github.com/mobz/elasticsearch-head5.0及以上版本安装参考地址:http://www.cnblogs.com/jstarseven/p/6036061.html 采用 git + node 的方式,所以安装前需要先安装好node,nod 阅读全文
posted @ 2019-07-17 11:08 努力挣扎的小兵 阅读(1010) 评论(0) 推荐(0)
摘要: elasticsearch默认的分词:http://localhost:9200/userinfo/_analyze?analyzer=standard&pretty=true&text=我是中国人 (或者不写analyzer=standard) 分词之后是:“我”“是”“中”“国”“人“,会将每一 阅读全文
posted @ 2019-07-17 11:07 努力挣扎的小兵 阅读(7172) 评论(0) 推荐(0)
摘要: github地址:https://github.com/NLPchina/elasticsearch-sql/ 方式一:github elasticsearch-sql上提供的安装方法cmd进入到本地的elasticsearch的bin目录。执行:plugin install https://git 阅读全文
posted @ 2019-07-17 11:05 努力挣扎的小兵 阅读(432) 评论(0) 推荐(0)
摘要: elasticsearch 5.0以下的版本要用到权限控制的话需要使用shield。下载地址: https://www.elastic.co/downloads/shield5.0以上的版本则可以使用X-Pack,shield现在只是x-pack的一部分。x-pack包含了Shield, Watch 阅读全文
posted @ 2019-07-17 11:03 努力挣扎的小兵 阅读(604) 评论(0) 推荐(0)
摘要: 官方文档:https://www.elastic.co/guide/en/shield/current/_using_elasticsearch_java_clients_with_shield.html 1.最简单的使用方式,全局配置凭据,使用此client时每个请求的请求头中都会带上凭据。Set 阅读全文
posted @ 2019-07-17 11:02 努力挣扎的小兵 阅读(271) 评论(0) 推荐(0)
摘要: 查看elasticsearch信息http://localhost:9200/ 查看某个索引信息http://localhost:9200/index_name例如:http://localhost:9200/twitter 查看某个文档http://localhost:9200/index_nam 阅读全文
posted @ 2019-07-17 11:01 努力挣扎的小兵 阅读(455) 评论(0) 推荐(0)
摘要: index的值只有三种(no,not_analyzed,analyzed)https://www.elastic.co/guide/en/elasticsearch/reference/2.4/mapping-index.htmlno:不添加到索引not_analyzed:添加到索引不分词analy 阅读全文
posted @ 2019-07-17 10:59 努力挣扎的小兵 阅读(7466) 评论(2) 推荐(0)
摘要: 1.创建索引并插入数据 Map json = new HashMap(); json.put("user", "kimchy5"); json.put("postDate", new Date()); json.put("message", "trying out Elasticsearch"); //参数设置 //Settings settings = Settings.settingsBui... 阅读全文
posted @ 2019-07-17 10:58 努力挣扎的小兵 阅读(2743) 评论(0) 推荐(0)
摘要: 1.集群名相同,且机器处于同一局域网同一网段,es会自动去发现其他的节点。2.集群不在同一局域网同一网段时,只需要在 elasticsearch.yml 中配置目标机器和端口即可discovery.zen.ping.unicast.hosts: ["10.127.0.1","10.127.0.2:9 阅读全文
posted @ 2019-07-17 10:56 努力挣扎的小兵 阅读(509) 评论(0) 推荐(0)
摘要: select owner,index_name,index_type from all_indexes where owner='xxxx' and table_name='xxx' select *from all_ind_columns where table_owner='xxx' and t 阅读全文
posted @ 2019-07-17 10:48 努力挣扎的小兵 阅读(640) 评论(0) 推荐(0)
摘要: mysql : insert into tablename (column1,column2) values ('aa','bb'), ('dd','cc'), ('ee','ff'); oracle:insert all into tablename (column1,column2) value 阅读全文
posted @ 2019-07-17 10:47 努力挣扎的小兵 阅读(9144) 评论(0) 推荐(1)
摘要: 1.自定义顺序 当我们希望将某个查询结果指定的显示顺序展示的时候 order by case when column1=1 then 0 case when column1=1 then 1 else 2 end decode也可以解决类似 2.对于null值的排序 在Oracle中,进行Order 阅读全文
posted @ 2019-07-17 10:46 努力挣扎的小兵 阅读(790) 评论(0) 推荐(1)
摘要: 1. 查某一用户下的表select SEGMENT_NAME,TABLESPACE_NAME,sum(BYTES/1024/1024)||'M' from USER_extents where SEGMENT_TYPE='TABLE'group by SEGMENT_NAME,TABLESPACE_ 阅读全文
posted @ 2019-07-17 10:43 努力挣扎的小兵 阅读(7007) 评论(0) 推荐(0)