• This repository has been archived on 17/Aug/2020
  • Stars
    star
    228
  • Rank 175,267 (Top 4 %)
  • Language
    Java
  • Created almost 12 years ago
  • Updated over 8 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Simple re-indexing. To backup, apply index settings changes and more ElasticMagic

Purpose

This plugin can be used to

  • update all or selected documents of an index, e.g. after you change the settings of a type
  • to change the index settings like shard count: create a new index with that config and reindex all documents into that index
  • grab all or selected documents from another elasticsearch cluster and feed your local machine with that
  • and more like a filtered backup etc
  • See ExampleUsage.java on how to use this plugin as simple rewriter of your content

License

Apache License 2.0

Installation

./reinstall.sh

you should see 'loaded [reindex], sites []' in the logs. Or use the reinstall.sh script for development purposes. Be sure to use elasticsearch 1.4.0. For newer versions - please provide pull requests ;)

Note: This script will build and install the plugin assuming elasticsearch is found in /usr/share/elasticsearch. The script will call 'sudo' on the install part, so the script should be run as a user with sudo privileges. Since maven will be used to build the plugin, it requires maven to be installed, which can be installed with the command below on a debian/ubuntu system.

sudo apt-get install maven2

Deinstallation

sudo $ES_HOME/bin/plugin remove reindex

sudo service elasticsearch restart

Usage

WARNINGs / TODOs:

  • Please try this on your local machine before using it in production - especially the case searchHost!=localhost could be problematic for your performance/IO
  • The call is not async and not stopable (except you stop the requested server) => The plugin should probably be better a river
  • If you have two servers on localhost and the queried server port is 9201 and you want to search the different server at 9200 => then you have to use e.g. searchHost=127.0.0.1&searchPort=9200

Same cluster

curl -XPUT 'http://localhost:9200/indexnew/typenew/_reindex?searchIndex=indexold&searchType=typeold' -d ' { "term" : { "count" : 2 } }'

This refeeds all documents in index 'indexold' with type 'typeold' into the index 'indexnew' with type 'typenew'. But only documents matching the specified filter will be refeeded. The internal Java API will be used which should be efficient. In this example, the term filter is used to limit the documents that will be reindexed, you can leave out the filter to copy all documents to the new index.

Same cluster with create index api

curl -XPUT 'http://localhost:9200/_reindex?index=indexnew&type=*&searchIndex=indexold'

This command creates the indexnew if not exist (the newIndexShards can be set to specify the number of shards). If type=* reindex all types from the index. If you want to skip some type and skipType=type1,type2

Different cluster

Now JSONObjects and the HttpClient will be used. TODO that is probably not efficient in terms of RAM/CPU?!:

curl -XPUT 'http://localhost:9200/indexnew/typenew/_reindex?searchIndex=indexold&searchType=typeold&searchHost=yourElasticsearchHost.com&searchPort=9200' -d ' { "term" : { "count" : 2 } }'

Further parameters:

  • hitsPerPage - used as search limit and at the same time for bulk indexing (default 100)
  • keepTimeInMinutes - the maximum time in minutes a scroll search is valid (default 30) increase if you have more data
  • withVersion - if the version of a document should be respected (default false)
  • waitInSeconds - pause the specified time after every request pair (one search+one bulkIndex). This avoids heavy load on the search or on the indexing server/cluster. This way it is very easy e.g. to grab even a massive amount of data from your production servers into your local machine.

Hints:

  • the index 'indexnew' and the type 'typenew' should exist.
  • the parameters 'searchIndex' and 'searchType' are optional and the new ones will be used if not provided
  • the filter is also optional

More Repositories

1

snacktory

Readability clone in Java
HTML
461
star
2

jsii

[not maintained] Full Text Search Prototype in JavaScript
JavaScript
87
star
3

Jetwick

[not maintained] Custom Twitter Search via ElasticSearch&Wicket
Java
61
star
4

graphhopper-traffic-data-integration

[not maintained] Traffic data integration example for GraphHopper
JavaScript
44
star
5

ElasticSearchExample

[not maintained] Example using ElasticSearch and a UI
Java
28
star
6

elasticsearch-rollindex

ElasticSearch plugin for rolling indices.
Java
28
star
7

graphhopper-osm-id-mapping

Example how to map internal node or edge IDs to OSM IDs
Java
22
star
8

java-duke-blender

Java Duke files for Blender
17
star
9

fastutil

github clone
Java
10
star
10

optaplanner-graphhopper-example

Example on how to use Optaplanner in combination with GraphHopper
Java
8
star
11

lumeo

Implementing Tinkerpop Blueprints API via Lucene (not yet done - see blueprint api tests!)
Java
7
star
12

ElasticSearch4Android

ElasticSearch for Android - experiment to get it running ...
Java
4
star
13

goreplay-java-middleware

Sketch of a Java middleware for goreplay
Java
4
star
14

languator

language detection for local names like street and POI names
Java
4
star
15

EbbeFlut

A really nice board game implemented in a bad way a VERY long time ago
Java
3
star
16

geocoder

Geocoder
Java
3
star
17

mvnrepo

Micro Maven Repo
3
star
18

xvantage

case study for simple java <-> xml binding
Java
2
star
19

map-companies

Visual Overview Of Current Map Companies
2
star
20

plotter

Simple plotter - aka genvlin plotter
Java
2
star
21

TestTwitterAPI

testing result discrepancy search vs. streaming API
Java
2
star
22

twittertool

TwitterTool
Java
2
star
23

directions-api-python

Experiments with the GraphHopper Directions API and python
HTML
1
star
24

iot-test

Record sensor data from ESP32 and show via browser graph (plotly)
C++
1
star
25

igniteexample

Java
1
star
26

mapsforge

Mapsforge clone from Ludwig. See rescue branch.
Java
1
star
27

openlr

OpenLR (not official)
Java
1
star
28

graphhopper-native-image

Experiments with GraphHopper: GraalVM native image execution
Java
1
star