elasticsearch数据增加并在每次重新启动时重复
我在Windows
7上将Elasticsearch与angularjs和oracle一起使用,它的工作原理越来越好(感谢stackoverflower帮助)。我对Elasticsearch有一个问题:我文档中的元素数量正在增加,我不知道为什么/如何做。我的由Elasticsearch索引的oracle表包含12010个元素,现在我在弹性文档中得到了84070个元素(通常由curl
_count检查):因此它现在将数据重复了7次。我几天前重新索引了表格,但之前删除了elasticsearch“ data”文件夹。
每次我重新启动Windows,数据似乎都会增加。
感谢帮助。
这是我安装和索引数据的方式:
我只是第一次这样做:
- 解压文件夹中的弹性文件:D:\ work \ elasticsearch-1.3.1 \
 - 安装Web界面:> plugin -install mobz / elasticsearch-head
 - install jdbc:>插件–install jdbc –url http://xbib.org/repository/org/xbib/elasticsearch/plugin/elasticsearch-river-jdbc/1.3.0.0/elasticsearch-river-jdbc-1.3.0.0- plugin.zip
 - 复制“ ojdbc6-11.2.0.3.jar”到“ D:\ work \ elasticsearch-1.3.1 \ plugins \ jdbc”
 - service.bat安装
 - service.bat开始
 
建立索引
curl -XPOST 'localhost:9200/donnees'映射:
curl -XPUT 'localhost:9200/donnees/specimens/_mapping' -d '{"specimens" : {
    "_all" : {"enabled" : true},
    "_index" : {"enabled" : true},
    "_id" : {"index": "not_analyzed", "store" : false},
    "properties" : {
        "O_OCCURRENCEID"                                : {"type" : "string",   "store" : "no","index": "not_analyzed"  } ,
            .... 
        "I_INSTITUTIONCODE"                             : {"type" : "string",   "store" : "yes","index": "analyzed" } 
    }
}}'
查询oracle和索引数据:
curl -XPUT 'localhost:9200/_river/donnees_s/_meta' -d '{ "type" : "jdbc",
 "jdbc" : {
    "index" : "donnees",
    "type" : "specimens",
    "url" : "jdbc:oracle:thin:@localhost:1523:recolnat",
     "user" : "user",
     "password" : "password",
     "sql" : "select * from all_specimens_data"
   }
}'
(这是正确的吗?如果我将“ curl -XPUT’localhost:9200 / donnees / specimens / _meta”替换为“
curl -XPUT’localhost:9200 / _river / donnees_s / _meta’”,则无法使用查询)
测试:
curl -XGET 'http://localhost:9200/donnees/specimens/_count?q=*'    => 12010
curl -XGET 'http://localhost:9200/donnees/specimens/_search?q=P00009359'
    => return data ok
回答:
已解决,感谢Konstantin V. Salikhov。
每次elasticsearch服务启动时,它都会使用提供给_river的sql查询数据库并获取数据(请参见前面的“查询oracle和索引数据:”)。如果数据中没有“
_id”列,则_river无法确定其已加载了哪些记录,并且每次都重复数据。为了避免重复,我在数据库中编辑了我的“
all_specimens_data”表(实际上是避免修改数据库的视图),并将“ O_OCCURRENCEID”重命名为“ _id”,“
O_OCCURRENCEID”是我的主键UUID。
希望这对其他人有帮助
以上是 elasticsearch数据增加并在每次重新启动时重复 的全部内容, 来源链接: utcz.com/qa/423321.html

