2017-08-31 6 views
0

私は100万行以上のデータセットを持っています。私は、logstashを使ってMysqlとelasticsearchを統合しました。 私は、次の 検索時に間違ったデータが表示される

http://localhost:9200/persondetails/Document/_search?q= *

は私が得る、郵便配達にフェッチするには、以下のURLを入力するとき:

{ 
"took": 1, 
"timed_out": false, 
"_shards": { 
    "total": 5, 
    "successful": 5, 
    "failed": 0 
}, 
"hits": { 
    "total": 2, 
    "max_score": 1, 
    "hits": [ 
     { 
      "_index": "persondetails", 
      "_type": "Document", 
      "_id": "%{idDocument}", 
      "_score": 1, 
      "_source": { 
       "iddocument": 514697, 
       "@timestamp": "2017-08-31T05:18:46.916Z", 
       "author": "vaibhav", 
       "expiry_date": null, 
       "@version": "1", 
       "description": "ly that", 
       "creation_date": null, 
       "type": 1 
      } 
     }, 
     { 
      "_index": "persondetails", 
      "_type": "Document_count", 
      "_id": "AV4o0J3OJ5ftvuhV7i0H", 
      "_score": 1, 
      "_source": { 
       "query": { 
        "term": { 
         "author": "rishav" 
        } 
       } 
      } 
     } 
    ] 
} 

}

それは私のテーブルの行数として間違っています100万以上であり、これは合計が2であることを示しています。私はここで間違いが何かを見つけることができません。オープン

  • インデックス:persondetails

  • UUID:4FiGngZcQfS0Xvu6IeHIfg

  • 状況黄:私はそれがこの

    1. 健康を示しhttp://localhost:9200/_cat/indices?v 入力

    2. PRI:5

    3. 担当者:1

    4. docs.count:2

    5. docs.deleted:1054

    6. store.size:125.4キロバイト

    7. pri.store.size:125.4kb

    これはあなたの結果から、私のlogstash.confファイル

    input { 
    jdbc { 
        jdbc_connection_string => "jdbc:mysql://127.0.0.1:3306/persondetails" 
        jdbc_user => "root" 
        jdbc_password => "" 
        schedule => "* * * * *" 
        jdbc_validate_connection => true 
        jdbc_driver_library => "/usr/local/Cellar/logstash/5.5.2/mysql-connector-java-3.1.14/mysql-connector-java-3.1.14-bin.jar" 
        jdbc_driver_class => "com.mysql.jdbc.Driver" 
        statement => "SELECT * FROM Document" 
        type => "persondetails" 
    } 
    } 
    output { 
    elasticsearch { 
        #protocol=>http 
        index =>"persondetails" 
        document_type => "Document" 
        document_id => "%{idDocument}" 
        hosts => ["http://localhost:9200"] 
        stdout{ codec => rubydebug} 
    } 
    } 
    
  • +0

    このレスポンスでは、合計は1つです。 – Val

    +0

    申し訳ありませんが、実際には2.合計は2になっていますが、私のテーブルには10行の行があります。 –

    +0

    異なるマッピングタイプがあります。あなたが 'GET http:// localhost:9200/persondetails/_search?q = *'を実行するとどうなるでしょうか? – Val

    答えて

    1

    あり、それはDOCUMENT_IDが生成取得されていないので、あなたの文書を上書きする原因となって、あなたのlogstash構成に問題があるように見え、かつ効果的に1つの文書のみでは、「{} idDocument%」

    はとしてドキュメントIDを使用してインデックスにありますが、提供された検索クエリに結果から、次の_sourceスニペットを参照してください。

    "_source": { 
          "iddocument": 514697, 
          "@timestamp": "2017-08-31T05:18:46.916Z", 
          "author": "vaibhav", 
          "expiry_date": null, 
          "@version": "1", 
          "description": "ly that", 
          "creation_date": null, 
          "type": 1 
    } 
    

    インデックスの小さなサイズを見ても、それ以上のドキュメントがあるようには見えません。 jdbc入力が "idDocument"フィールドを提供しているかどうかを調べる必要があります。

    +0

    はい、ありがとうございます。 confファイルのidDocumentからiddocumentに変更しました。私はなぜ列名が私のテーブルのidDocumentであるので、これが起こっているのかわかりません。 jdbcinputがiddocumentに変更しているようです。 –

    +0

    こんにちは@VaibhavSavala、あなたは大歓迎です。 jdbcの入力入力定義で "lowercase_column_names => false"を使用すると、それを止めることができます。この旗の輪郭はhttps://www.elastic.co/guide/en/logstash/current/plugins-inputs-jdbc.html#plugins-inputs-jdbc-lowercase_column_namesです。これがあなたの質問に答えるなら、それを受け入れることを検討してください(https://meta.stackexchange.com/q/5234/179419) – Animesh

    関連する問題