elasticsearch 自定义_id

elasticsearch 自定义ID:

curl -s -XPUT localhost:9200/web -d ‘
{
    "mappings": {
        "blog": {
            "_id": {
                "path": "uuid"
            },
            "properties": {
                "title": {
                    "type":   "string",
                    "index":  "analyzed"
                }
            }
        }
    }
}‘

启动本地es,然后写入数据,data2.json:

{ "index":  { "_index": "web", "_type": "blog", "_id": "123" }}
{"title":    "But we can update it" }
{ "index":  { "_index": "web", "_type": "blog", "_id": "123" }}
{ "title":    "But we can update it" }
{ "index":  { "_index": "web", "_type": "blog"}}
{ "title":    "But we can update it", "uuid": "3210"}

通过批量插入上述数据:

curl -s -XPOST localhost:9200/_bulk --data-binary @data2.json
{"took":3,"errors":false,"items":[{"index":{"_index":"web","_type":"blog","_id":"123","_version":5,"status":200}},{"index":{"_index":"web","_type":"blog","_id":"123","_version":6,"status":200}},{"index":{"_index":"web","_type":"blog","_id":"3210","_version":3,"status":200}}]}

可以看到新生成的文档_id为uuid的数值!

时间: 2024-08-09 13:02:50

elasticsearch 自定义_id的相关文章

Elasticsearch 自定义多个分析器

分析器(Analyzer) Elasticsearch 无论是内置分析器还是自定义分析器,都由三部分组成:字符过滤器(Character Filters).分词器(Tokenizer).词元过滤器(Token Filters). 分析器Analyzer工作流程: Input Text => Character Filters(如果有多个,按顺序应用) => Tokenizer => Token Filters(如果有多个,按顺序应用) => Output Token 字符过滤器(C

elasticsearch 自定义similarity 插件开发

原文  http://www.cnblogs.com/luanfei/p/4029442.html 主题 Elastic Search 转自: http://www.chepoo.com/elasticsearch-similarity-custom-plug-in-development.html 在搜索开发中,我们要修改打分机制,就需要自定义similarity.现在来简单说一下elasticsearch下的自定义similarity 插件开发. 网上的 https://github.com

ElasticSearch自定义分析器-集成结巴分词插件

关于结巴分词 ElasticSearch 插件: https://github.com/huaban/elasticsearch-analysis-jieba 该插件由huaban开发.支持Elastic Search 版本<=2.3.5. 结巴分词分析器 结巴分词插件提供3个分析器:jieba_index.jieba_search和jieba_other. jieba_index: 用于索引分词,分词粒度较细: jieba_search: 用于查询分词,分词粒度较粗: jieba_other:

ElasticSearch——自定义模板

output中配置 elasticsearch{ action => "index" hosts => ["xxx"] index => "http-log-logstash" document_type => "logs" template => "opt/http-logstash.json" template_name => "http-log-logst

Elasticsearch自定义脚本完成性能测试

1.ES性能测试 要求: 1)完成ES并发100次性能测试: 2)统计得出访问时间结果值. 2.脚本实现 #!/bin/sh KEYWORDS_TXT="./keywords.txt" cat /dev/null > ./rst.txt echo "beginTime=`date`" cat $KEYWORDS_TXT | while read line do echo "line=$line" echo "curl -XGET

elasticsearch 自定义打分

curl -XGET 'http://localhost:9200/searchsuggestion/searchsuggestion/_search?pretty' -d '{ "fields" : ["company_full_name","id"], "size" : 10, "query": { "function_score": { "functions":

filebrat6.8多路径日志输出到elasticsearch自定义多个索引

原文地址:https://blog.51cto.com/12102819/2481956

ElasticSearch 5.4 自定义插件

ElasticSearch 做为数据仓库处理速度确实很强,但是很多和业务相关的函数ElasticSearch怎么支持的,通过查询发现,ElasticSearch支持自定义插件(相当于自定义函数),通过自定义插件,开发人员可以实现各种业务相关的函数定义供相关人员使用. 1.   ElasticSearch  自定义插件编写 后续补充. 2.  ElasticSearch  自定义插件打包 2.1  自定义插件开发完成后,需要增加“plugin-descriptor.properties”配置文件,

ElasticSearch如何添加,检索数据

Elasticsearch是一个分布式的文档(document)存储引擎.它可以实时存储并检索复杂数据结构--序列化的JSON文档.换言说,一旦文档被存储在Elasticsearch中,它就可以在集群的任一节点上被检索. 当然,我们不仅需要存储数据,还要快速的批量查询.虽然已经有很多NoSQL的解决方案允许我们以文档的形式存储对象,但它们依旧需要考虑如何查询这些数据,以及哪些字段需要被索引以便检索时更加快速. 程序中大多的实体或对象能够被序列化为包含键值对的JSON对象,键(key)是字段(fi