社区所有版块导航
Python
python开源   Django   Python   DjangoApp   pycharm  
DATA
docker   Elasticsearch  
aigc
aigc   chatgpt  
WEB开发
linux   MongoDB   Redis   DATABASE   NGINX   其他Web框架   web工具   zookeeper   tornado   NoSql   Bootstrap   js   peewee   Git   bottle   IE   MQ   Jquery  
机器学习
机器学习算法  
Python88.com
反馈   公告   社区推广  
产品
短视频  
印度
印度  
Py学习  »  Elasticsearch

ElasticSearch更新无法识别/禁用文档版本控制

Marcel • 5 年前 • 626 次点击  

我使用的是elasticsearch 6.5.4——目前我每天都会通过post-ajax调用将数据直接写入几个索引中,其中的id总是相同的。弹性然后返回我,如果ID不存在,文档被创建-或者如果ID存在,文档被更新。

现在我遇到了一个版本控制的问题,因为它似乎值不更新。通过elastichead扩展,我正在查看文档的详细信息,我可以看到,例如,我将文档存储为“版本9”,但诸如索引时间戳之类的数据字段仍然是“版本1”中的字段。

我已经检查过了,实际上我并没有存储所有的版本——只是最新的版本。Elastic只是保留了版本的索引。所以我不太确定,比如时间戳为什么不更新。

我想要的,基本上是禁用版本控制或以某种方式告诉弹性每一个后调用,我正在索引的文件是当前的,它应该只使用当前的一个显示。我发现的所有类似的问题都不能完全复制我的问题,而且没有一个解决方案能够解决它。

这个问题是因为我使用了一个简单的post-ajax调用吗?可以通过使用logstash作为摄取管道来解决这个问题吗(我计划在进一步的项目进展中做这项工作)?

例子:

Data sent to Elastic
ajax.call - method.post - Result: 200
https://elasticURL.com/article/123456
{
     "customer": "Customer",
     "source": "Source",
     "categories": "/Category1/Category2/Category3/",
     "title": "My Title",
     "articletype": "MyType",
     "rating": 100,
     "ratingnormalized": 5,
     "views": 1234,
     "author": "Author",
     "timeindexed": "21/1/2019 10:00",
     "timeindexedDate": "21/1/2019",
     "timecreated": "13/10/2018 11:22",
     "timecreatedDate": "13/10/2018 ",
     "timeupdated": "13/10/2018 11:22",
     "timeupdatedDate": "13/10/2018 ",
     "url": "https://www.google.com",
     "category1": "Category: 1",
     "category2": "Category: 2",
     "category3": "Category: 3",
     "text": "MyText ",
     "html": "<html></html>"
}
Data stored in Elastic
{
"_index": "index_name",
"_type": "article",
"_id": "123456",
"_version": 3,
"_score": 1,
"_source": {
     "customer": "Customer",
     "source": "Source",
     "categories": "/Category1/Category2/Category3/",
     "title": "My Title",
     "articletype": "MyType",
     "rating": 100,
     "ratingnormalized": 5,
     "views": 1234,
     "author": "Author",
     "timeindexed": "04/1/2019 01:05",
     "timeindexedDate": "04/1/2019",
     "timecreated": "13/10/2018 11:22",
     "timecreatedDate": "13/10/2018 ",
     "timeupdated": "13/10/2018 11:22",
     "timeupdatedDate": "13/10/2018 ",
     "url": "https://www.google.com",
     "category1": "Category: 1",
     "category2": "Category: 2",
     "category3": "Category: 3",
     "text": "MyText ",
     "html": "<html></html>"
  }
}

索引创建

PUT - https://elasticURL.com/index_name
{
    "settings" : {
        "index" : {
            "number_of_shards" : 5, 
            "number_of_replicas" : 0 
        }
    }
}

索引映射

PUT - https://elasticURL.com/index_name/_mappings
{
    "properties" : {
        "customer" : { "type" : "text" },
        "source" : { "type" : "text" },
        "categories" : { "type" : "text" },
        "articletype" : { "type" : "text" },    
        "title" : { "type" : "text" },
        "rating" : { "type" : "integer" },
        "ratingnormalized" : { "type" : "integer" },
        "views" : { "type" : "integer" },
        "author" : { "type" : "text" },
        "timeindexed" : { "type" : "date", "format" : "dd/MM/yyyy HH:mm"},
        "timeindexeddate" : { "type" : "date", "format" : "dd/MM/yyyy"},
        "timecreated" : { "type" : "date", "format" : "dd/MM/yyyy HH:mm"},
        "timecreateddate" : { "type" : "date", "format" : "dd/MM/yyyy"},
        "timeupdated" : { "type" : "date", "format" : "dd/MM/yyyy HH:mm"},
        "timeupdateddate" : { "type" : "date", "format" : "dd/MM/yyyy"},
        "url" : { "type" : "text" },
        "category1" : { "type" : "text" },
        "category2" : { "type" : "text" },
        "category3" : { "type" : "text" },
        "text" : { "type" : "text" },
        "html" : { "type" : "text" }
    }
}
+ keyword mapping for text fields, eg
        "text": {
            "type": "text",
            "fields": {
                "keyword": {
                    "ignore_above": 256,
                    "type": "keyword"
                }
            }
        },

快速总结这一点; 例如,字段timeindexed,不更新新的post来更新数据。只有版本增加。弹性指数显示文件:4.498(5.320)。

Python社区是高质量的Python/Django开发社区
本文地址:http://www.python88.com/topic/47885
 
626 次点击