2

신축성있는 검색 기능을 설치했으며 로컬 서버에 인제 스트 플러그인을 설치했습니다. 탄성 엔진이 잘 작동합니다. 나는 다음과 같은 작업 설정 :검색 결과 (Elastic Search)가 PHP에서 작동하지 않습니다.

  1. 매핑
  2. 색인

지금은 검색에 갇혀 오전, 제대로 동작하지 않습니다. 널 배열을 리턴합니다. 다음은 PHP에서 내 코드는 다음과 같습니다

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; 
} 

결과 :

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

하지만이 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=" 
    } 
} 

내가 한 실수는 무엇인가에 대한 데이터를?

+0

을 당신이 당신의 매핑을 보여줄 수 있다면? – Kulasangar

답변

0

복수 값이 일치하지 않으므로 'textField' => $query에서 ,을 삭제 해보세요. 여전히 작동하지 않는 경우, match 대신 term 쿼리를 사용하려고 :

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