Puneeth P
Puneeth P

Reputation: 155

UnavailableShardsException

I want to index and search mysql database using elasticsearch & I followed this tutorial

https://github.com/jprante/elasticsearch-river-jdbc/wiki/Quickstart

At first I downloaded elasticsearch and installed river-jdbc in its plugin folder. then added mysql-jdbc inside ES_HOME/plugins/river-jdbc/ Then started elasticsearch and Started another terminal window, and created a new JDBC river with name my_jdbc_river with this curl command

curl -XPUT 'localhost:9200/_river/my_jdbc_river/_meta' -d '{
    "type" : "jdbc",
    "jdbc" : {
        "driver" : "com.mysql.jdbc.Driver",
        "url" : "jdbc:mysql://localhost:3306/bablool",
        "user" : "root",
        "password" : "babloo",
        "sql" : "select * from details"
    },
    "index" : {
        "index" : "jdbc",
        "type" : "jdbc"
    }
}'

I'm getting the following error:-

then when I run this command: curl -XGET 'localhost:9200/jdbc/jdbc/_search?pretty&q=*'

and I'm getting following error:

"error": "IndexMissingException[[jdbc] missing]", "status" : 404

And when I give this in my browser:

http://localhost:9201/_search?q=*

Im getting like this:

{
  "took": 51,
  "timed_out": false,
  "_shards": {
    "total": 1,
    "successful": 1,
    "failed": 0
  },
  "hits": {
    "total": 1,
    "max_score": 1.0,
    "hits": [
      {
        "_index": "_river",
        "_type": "my_jdbc_river",
        "_id": "_meta",
        "_score": 1.0,
        "_source": {
          "type": "jdbc",
          "jdbc": {
            "driver": "com.mysql.jdbc.Driver",
            "url": "jdbc:mysql://localhost:3306/bablool",
            "user": "root",
            "password": "babloo",
            "sql": "select * from details"
          },
          "index": {
            "index": "jdbc",
            "type": "jdbc"
          }
        }
      }
    ]
  }
}

Is mysql dB indexed? How can I Search in my Db?

Upvotes: 2

Views: 692

Answers (1)

Punit
Punit

Reputation: 33

I encountered similar problem and this is how I managed to solve the issue:

Firstly, I checked all the indices via http://localhost:9200/_cat/indices?v

Deleted all indices with health status as red (there was just one index _river with health status red)

This is how you delete in index curl -XDELETE 'localhost:9200/_river/'

Redo step 7 in link you mentioned https://github.com/jprante/elasticsearch-river-jdbc/wiki/Quickstart

Hope it solves your problem as well :) Good luck!!

Upvotes: 0

Related Questions