Doc can be found by query but not by get

I have indexed a few documents for some users and I can find any of them by id, eg:

GET /athlete/_search?q=id:19
(returns my athlete in _source):

{
  "took": 2,
  "timed_out": false,
  "_shards": {
    "total": 5,
    "successful": 5,
    "skipped": 0,
    "failed": 0
  },
  "hits": {
    "total": 1,
    "max_score": 1,
    "hits": [
      {
        "_index": "athlete",
        "_type": "doc",
        "_id": "19",
        "_score": 1,
        "_source": {
          "type": "athlete",
          "firstname": "Cristi",
          "id": 19,
          "fullname": "Cristi B",
          "followers": 2,
          "lastname": "Boariu",
          "username": "cristiboariuok",
          "urlthumb": "http://www.google.com",
          "@version": "1",
          "@timestamp": "2018-08-10T11:05:02.185Z"
        }
      }
    ]
  }
}

but when I try to get that specific doc by id:
GET /athlete/_doc/19

it returns:

{
  "_index": "athlete",
  "_type": "_doc",
  "_id": "19",
  "found": false
}

Can anybody give a helping hand please?

Did you use routing function by any chance? Or Parent/Child feature?

No...

This is the logstash script I built to import data from mysql into ES:

input {
  jdbc { 
    jdbc_connection_string => "jdbc:mysql://ip/admin"
    # The user we wish to execute our statement as
    jdbc_user => "root"
    jdbc_password => "pwd"
    # The path to our downloaded jdbc driver
    jdbc_driver_library => "/user/share/logstash/mysql-connector-java-5.1.46.jar"
    jdbc_driver_class => "com.mysql.jdbc.Driver"
    tracking_column => "id"
    use_column_value => true
    schedule => "* * * * *"
    # our query
    statement => "
    SELECT 
    	u.id,
        u.username,
        u.firstName,
        u.lastName,
        CONCAT(u.firstName, ' ', u.lastName) as fullName,
        u.type,
        u.followers,
        a.urlThumb
    FROM user u
    LEFT JOIN
        asset a ON a.id = u.imageId
    WHERE u.type = 'athlete';"
    }
}

output {
  elasticsearch {
    hosts => ["https://host:9243"]
    index => "athlete"
    user => "elastic"
    password => "pwd"
    document_id => "%{id}"
    action => index
  }
  stdout {
    codec => rubydebug
  }
}

What is the output of

GET athlete/_settings
{
  "athlete": {
    "settings": {
      "index": {
        "creation_date": "1533897887106",
        "number_of_shards": "5",
        "number_of_replicas": "1",
        "uuid": "XEvXcd_5RTGr3xPgeeihAw",
        "version": {
          "created": "6030199"
        },
        "provided_name": "athlete"
      }
    }
  }
}

Oh I see.

There is a typo between doc and _doc.

Try:

GET athlete/doc/19

Thanks a lot...It works indeed.

But please note that here https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-get.html is: _doc, eg:

GET twitter/_doc/0

This is true but the doc type you have in your case is doc and not _doc.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.