Reputation: 23500
Browsing to: http://127.0.0.1:9200/wham/_search
Gives me:
{
"error": "IndexMissingException[[wham] missing]",
"status": 404
}
I've set everything up according to these documentations:
The last one being the most helpful at the moment.
That sad, I've used two different "setup" queries via curl to create my river:
curl -XPUT 'localhost:9200/_river/wham/_meta' -d '{
"type": "jdbc",
"jdbc": {
"url": "jdbc:postgresql://localhost:5432/testdb",
"user": "postgres",
"password": "passywordu",
"index": "source",
"type": "wham",
"sql": "select * from testtable;"
}
}'
And then I've tried this which is a modified version of the last link above.
curl -XPUT 'localhost:9200/_river/wham/_meta' -d '{
"type": "jdbc",
"jdbc": {
"strategy": "simple",
"poll": "5s",
"scale": 0,
"autocommit": false,
"fetchsize": 10,
"max_rows": 0,
"max_retries": 3,
"max_retries_wait": "10s",
"url": "jdbc:postgresql://localhost:5432/testdb",
"user": "postgres",
"password": "passywordu",
"sql": "select * from testtable",
"index": "wham"
}
}'
I'm currently using the last of the curls and http://127.0.0.1:9200/_river/wham/_status
gives me this:
{
"_index": "_river",
"_type": "wham",
"_id": "_status",
"_version": 4,
"found": true,
"_source": {
"node": {
"id": "v1DmcsEOSbKfEbjRdwLYOg",
"name": "Miles Warren",
"transport_address": "inet[/192.168.43.211:9300]"
}
}
}
So the river is there, I do however not see any queries arriving in my postgresql database engine. Which I've set up accordingly:
su - postgres
initdb --locale en_US.UTF-8 -E UTF8 -D '/tmp/testdb'
postgres -D /tmp/testdb
createdb testdb
psql -d testdb
CREATE TABLE testtable (
source varchar(20) NOT NULL,
destination varchar(20) NOT NULL,
service int, NOT NULL
);
INSERT INTO testtable VALUES('192.168.0.10', '192.168.0.1', 80)
INSERT INTO testtable VALUES('192.168.0.11', '192.168.0.2', 21)
I can query the database on the default port, it runs fine with the username and password.
Where have I gone wrong? Have I misunderstood elasticsearch or shouldn't I be able to do /wham/_search
and get all the results from mentioned SQL query?
Upvotes: 4
Views: 7437
Reputation: 5747
I think you are confused with queries
Query 1)
curl -XPUT 'localhost:9200/_river/wham/_meta' -d '{
"type" : "jdbc",
"jdbc" : {
"url" : "jdbc:postgresql://localhost:5432/testdb",
"user" : "postgres",
"password" : "passywordu",
"index" : "source",
"type" : "wham",
"sql" : "select * from testtable;"
}
}'
while using above query
you create an index named "source". With in that you create a index type of wham. so after executing above curl. You need query for data using following format
http://127.0.0.1:9200/source/wham/_search
it means search data inside index "source" and type "wham".
Query 2)
curl -XPUT 'localhost:9200/_river/wham/_meta' -d '{
"type" : "jdbc",
"jdbc" : {
"strategy" : "simple",
"poll" : "5s",
"scale" : 0,
"autocommit" : false,
"fetchsize" : 10,
"max_rows" : 0,
"max_retries" : 3,
"max_retries_wait" : "10s",
"url" : "jdbc:postgresql://localhost:5432/testdb",
"user" : "postgres",
"password" : "passywordu",
"sql" : "select * from testtable",
"type": "typename", //add the type of documents to be indexed[like tables in RDBMS]
"index" : "wham"
}
}'
while using above query
you create an index named "wham". With in that you create a index type of wham. so after executing above curl. You need query for data using following format
http://127.0.0.1:9200/wham/typename/_search [or]
http://127.0.0.1:9200/wham/_search
it means search data inside index "wham" and indextype "typename".
before try above curl.delete the _river index and try.If the data is not important clear the data folder and try..!
Hope it helps..!
Upvotes: 5