https://www.elastic.co/cn/downloads/elasticsearch
$ cd bin
$ ./elasticsearch
https://zhuanlan.zhihu.com/p/74408145
Master-Slave模式,Master进行集群和元数据管理,Data Node作为Slave节点,负责实际数据的索引和搜索操作。
https://baijiahao.baidu.com/s?id=1707530675869255847&wfr=spider&for=pc
https://blog.csdn.net/qq_21383435/article/details/117065422
% curl http://127.0.0.1:9200/_all
curl: (52) Empty reply from server
[2022-04-17T08:36:16,736][WARN ][o.e.x.s.t.n.SecurityNetty4HttpServerTransport] [xiazemindeMBP] received plaintext http traffic on an https channel, closing connection Netty4HttpChannel{localAddress=/127.0.0.1:9200, remoteAddress=/127.0.0.1:62886}
% cat config/elasticsearch.yml
https://wenku.baidu.com/view/f8b9fd3f2179168884868762caaedd3383c4b5d6.html
curl -H “Content-Type:application/json” -XPOST -u elastic ‘http://127.0.0.1:9200/_xpack/security/user/elastic/_password’ -d ‘{ “password” : “123456” }’
curl -XGET –user user:passwd ‘http://XXXX:9200/XX/XXX’
https://blog.csdn.net/mengo1234/article/details/104989382
% ./bin/elasticsearch-setup-passwords interactive
Failed to authenticate user ‘elastic’ against https://192.168.31.98:9200/_security/_authenticate?pretty
Possible causes include:
You can use the elasticsearch-reset-password
CLI tool to reset the password of the ‘elastic’ user
ERROR: Failed to verify bootstrap password
./bin/elasticsearch-reset-password -u elastic
Password for the [elastic] user successfully reset.
New value: OngoP+zAoLtfOU-MDPr=
curl -XGET –user elastic:OngoP+zAoLtfOU-MDPr= ‘http://127.0.0.1:9200/_all’
[2022-04-17T08:52:45,529][WARN ][o.e.x.s.t.n.SecurityNetty4HttpServerTransport] [xiazemindeMBP] received plaintext http traffic on an https channel, closing connection Netty4HttpChannel{localAddress=/127.0.0.1:9200, remoteAddress=/127.0.0.1:64182}
修改elasticsearch.yml配置文件
将xpack.security.enabled设置为false
xpack.security.enabled: false
https://blog.csdn.net/qq_17229141/article/details/123106584
% curl -XGET –user elastic:OngoP+zAoLtfOU-MDPr= ‘http://127.0.0.1:9200’
{
“name” : “xiazemindeMBP”,
“cluster_name” : “elasticsearch”,
“cluster_uuid” : “MIsFIwcpShSyPd20uwsrCw”,
“version” : {
“number” : “8.1.2”,
“build_flavor” : “default”,
“build_type” : “tar”,
“build_hash” : “31df9689e80bad366ac20176aa7f2371ea5eb4c1”,
“build_date” : “2022-03-29T21:18:59.991429448Z”,
“build_snapshot” : false,
“lucene_version” : “9.0.0”,
“minimum_wire_compatibility_version” : “7.17.0”,
“minimum_index_compatibility_version” : “7.0.0”
},
“tagline” : “You Know, for Search”
}
https://github.com/medcl/elasticsearch-analysis-ik/releases
Exception in thread “main” java.nio.file.NotDirectoryException:
/Users/xiazemin/Downloads/软件/elasticsearch-8.1.2/plugins/elasticsearch-analysis-ik-8.1.2.jar
% rm .DS_Store
https://blog.csdn.net/weixin_49307485/article/details/120656211
cd your-es-root/plugins/ && mkdir ik
unzip plugin to folder your-es-root/plugins/ik
https://github.com/medcl/elasticsearch-analysis-ik
% curl -XGET –user elastic:OngoP+zAoLtfOU-MDPr= ‘http://127.0.0.1:9200/_cat/plugins’
xiazemindeMBP analysis-ik 8.1.2
curl -XPUT –user elastic:OngoP+zAoLtfOU-MDPr= –header ‘Content-Type: application/json’ –header ‘Accept: application/json’ -d ‘{“mappings”:{“properties”:{“category”:{“type”:”text”},”title”:{“type”:”text”},”content”:{“analyzer”:”ik_max_word”,”search_analyzer”:”ik_max_word”,”type”:”text”}}}}’ ‘http://127.0.0.1:9200/my_blog’
{“error”:{“root_cause”:[{“type”:”invalid_index_name_exception”,”reason”:”Invalid index name [myBlog], must be lowercase”,”index_uuid”:”na”,”index”:”myBlog”}],”type”:”invalid_index_name_exception”,”reason”:”Invalid index name [myBlog], must be lowercase”,”index_uuid”:”na”,”index”:”myBlog”},”status”:400}
{“error”:{“root_cause”:[{“type”:”access_control_exception”,”reason”:”access denied ("java.io.FilePermission" "/Users/xiazemin/Downloads/%E8%BD%AF%E4%BB%B6/elasticsearch-8.1.2/plugins/ik/config/IKAnalyzer.cfg.xml" "read")”}],”type”:”access_control_exception”,”reason”:”access denied ("java.io.FilePermission" "/Users/xiazemin/Downloads/%E8%BD%AF%E4%BB%B6/elasticsearch-8.1.2/plugins/ik/config/IKAnalyzer.cfg.xml" "read")”},”status”:500}
% chmod 777 ./ik
chmod 777 ./ik/config/IKAnalyzer.cfg.xml
解决方案:
1、分析为配置文件IKAnalyzer.cfg.xml只有可读权限 给予文件相对应的权限
2、es 如果装了插件,路径文件夹不能有空格或者汉字
https://blog.csdn.net/qq_42681313/article/details/106277140
{“acknowledged”:true,”shards_acknowledged”:true,”index”:”my_blog”}
% go mod init es
go: creating new go.mod: module es
% go get -u github.com/olivere/elastic/v7
https://blog.csdn.net/hanzkering/article/details/84844367
1)以下情况
a.如果将request.docAsUpsert(true) 和request.scriptedUpsert(true)注释掉或都设置为false,
b.如果将request.docAsUpsert(true) 设置为faluse,而request.scriptedUpsert(true)为true
且文档不存在,则创建出来的文档内容为:
{“created”:”2017-01-01”},
即只有request.upsert(jsonString, XContentType.JSON)中的jsonString内容被创建,而request.doc(jsonMap)中的jsonMap内容没被创建
2)此例中如果文档不存在,且这样设置:request.scriptedUpsert(true);、request.docAsUpsert(false);,则会创建一个空内容的文档,因为脚本中没有内容,而禁止通过doc秋冬装创建新文档
3)如果不使用request.upsert方法,且request.scriptedUpsert(false);和request.docAsUpsert(false);都设置为false,
则文档不存在时提示没有找到文档,而不会创建新的文档
4)如果request.docAsUpsert(true)和request.scriptedUpsert(true)都设置为true,且
request.doc(jsonMap)被注释掉时,会报错如下:
org.elasticsearch.action.ActionRequestValidationException:
Validation Failed: 1: script or doc is missing;2: doc must be specified if doc_as_upsert is enabled;
即如果开启动了doc_as_upsert方法,则必须使用doc方法传入需要更新的内容
5)注:单机不要使用如下方法,否则会报超时异常
// request.waitForActiveShards(2);
// request.waitForActiveShards(ActiveShardCount.ALL);
https://blog.csdn.net/qq_2300688967/article/details/83826118
{“error”:{“root_cause”:[{“type”:”action_request_validation_exception”,”reason”:”Validation Failed: 1: script or doc is missing;”}],”type”:”action_request_validation_exception”,”reason”:”Validation Failed: 1: script or doc is missing;”},”status”:400}
elastic: Error 400 (Bad Request): Validation Failed: 1: script or doc is missing; [type=action_request_validation_exception]
//Upsert(data).
Doc(data).
// true 无则插入, 有则更新, 设置为false时记录不存在将报错
DocAsUpsert(true).
这里不能用 Upsert
转换Markdown语法:russross/blackfriday
查找Document的内容:PuerkitoBio/goquery
语法高亮:sourcegraph/syntaxhighlight
插入模块:html/template
执行外部命令:os/exec
文件操作:path/filepath
创建Web服务器:SimpleHTTPServer
解析.yml配置文件:gopkg.in/yaml.v2
https://renwoxing.blog.csdn.net/article/details/108592511?spm=1001.2101.3001.6650.1&utm_medium=distribute.pc_relevant.none-task-blog-2%7Edefault%7ECTRLIST%7ERate-1.pc_relevant_aa&depth_1-utm_source=distribute.pc_relevant.none-task-blog-2%7Edefault%7ECTRLIST%7ERate-1.pc_relevant_aa&utm_relevant_index=2
go get github.com/PuerkitoBio/goquery #查找Document的内容,这个库就实现了类似 jQuery 的功能,让你能方便的使用 Go 语言操作 HTML 文档
go get github.com/sourcegraph/syntaxhighlight #语法高亮syntaxhighlight包提供代码的语法高亮显示。 它目前使用独立于语言的词法分析器, 并在JavaScript,Java,Ruby,Python,Go和C上表现出色。
#主要的AsHTML(src []byte) ([]byte, error)函数,输出就是HTML 与google-code-prettify相同的CSS类,因此任何样式表也应该适用于此包。