2017-01-22 16 views
2

私は弾性検索をインストールしており、インジェストプラグインもローカルサーバーにインストールしています。弾性のエンジンはうまく動作しています。私は、次のタスクを設定します。今、私はそれが働いていない、検索で立ち往生していますインジェスト検索(Elastic Search)がPHPで動作しません

  1. マッピング
  2. インデックス

。ヌル配列を返します。

public function ingest_processor_searching($query) 
{ 
    $client = $this->client; 
    $params = [ 
     'index' => 'ingest_index', 
     'type' => 'attachment', 
     'body' => [ 
      'query' => [ 
       'match' => [ 
        'textField' => $query, 
       ] 
      ], 
     ], 
    ]; 

    $response = $client->search($params); 
    return $response; 
} 

結果:ここに私のコードはPHPであるGET http://localhost:9200/ingest_index/attachment/2

{ 
    "_index": "ingest_index", 
    "_type": "attachment", 
    "_id": "2", 
    "_version": 1, 
    "found": true, 
    "_source": { 
    "file_path": "/Users/selimreza/Sites/haber_dev/public/uploads/files/bower.txt", 
    "attachment": { 
     "content_type": "text/plain; charset=ISO-8859-1", 
     "language": "en", 
     "content": "Welcome to Dhaka", 
     "content_length": 18 
    }, 
    "textField": "V2VsY29tZSB0byBEaGFrYQo=" 
    } 
} 

ため

{ 
"took": 7, 
"timed_out": false, 
"_shards": { 
    "total": 5, 
    "successful": 5, 
    "failed": 0 
}, 
    "hits": { 
    "total": 0, 
    "max_score": null, 
    "hits": [] 
} 
} 

しかし、私はデータを持っている私は間違いとは何ですか?

+0

あなたのマッピングを示すことができた場合は? – Kulasangar

答えて

0

複数の値が一致していないため、'textField' => $queryから,を削除してみます。それでも動作しない場合は、代わりにmatchtermクエリを使用してみてください:

$params = [ 
     'index' => 'ingest_index', 
     'type' => 'attachment', 
     'body' => [ 
      'query' => [ 
       'term' => [ <-- have this 
        'textField' => $query <-- try removing the comma 
       ] 
      ], 
     ], 
    ]; 
関連する問題