Elasticsearch 数据在每次重新启动时增加和重复



我在windows7上使用angularjs和oracle的弹性搜索。它越来越有效&更精细(感谢stackoverflower的帮助)。我对弹性搜索有一个问题:我的文档中的元素数量在增加,我不知道为什么/如何增加。我的弹性搜索索引的oracle表包含12010个元素,现在我在弹性文档中得到了84070个元素(经常被curl_count检查):所以它现在重复了7次数据。我几天前重新索引了表,但我之前删除了弹性搜索"数据"文件夹。

每次重新启动windows时,数据似乎都在增加。

谢谢你的帮助。

这就是我如何安装和索引我的数据:


我只是第一次这样做:

  • 解压缩文件夹中的松紧带:D:\work\elasticsearch-1.3.1\
  • 安装web界面:>插件-安装mobz/elasticsearch-head
  • 安装jdbc:>plugin-installjdbc--urlhttp://xbib.org/repository/org/xbib/elasticsearch/plugin/elasticsearch-river-jdbc/1.3.0.0/elasticsearch-river-jdbc-1.3.0.0-plugin.zip
  • 将"ojdbc6-1.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/river/donnees_s/_meta'"替换"curl XPUT'localhost:92000/donnees/samples/_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。

希望这能帮助其他

最新更新