3

Searching is not working in Ingest Processor in ElasticSearch

Here is the mapping code

public function ingest_processor_mapping()
{
    $client = \Elasticsearch\ClientBuilder::create()->build();
    $params = [
        'id' => 'attachment',
        'body' => [
            'description' => 'Extract attachment information',
            'processors' => [
                [
                    'attachment' => [
                        'field' => 'content',
                        'indexed_chars' => -1
                    ]
                ]
            ]
        ],

    ];
    return $client->ingest()->putPipeline($params);
}  

Result ::

{
 "acknowledged": true
}

Here is my Indexing Code in PHP

public function ingest_processor_indexing()
{
    $client = \Elasticsearch\ClientBuilder::create()->build();
    $fullfile = public_path().'/uploads/files/bower.pdf';
    $params = [
        'index' => 'ingest_index',
        'type'  => 'attachment',
        'id'    => 'document_id',
        'pipeline' => 'attachment',  // <----- here
        'body'  => [
            'content' => base64_encode(file_get_contents($fullfile)),
            'file_path' =>$fullfile,
        ]
    ];
    return $client->index($params);
}

Result ::

 {
  "_index": "ingest_index",
  "_type": "attachment",
  "_id": "document_id",
  "_version": 2,
  "result": "updated",
  "_shards": {
"total": 2,
"successful": 1,
"failed": 0
  },
  "created": false
}

Here is my searching CODE in PHP ::

public function ingest_processor_searching()
{
    $client = \Elasticsearch\ClientBuilder::create()->build();
    $params = [
        'index' => 'ingest_index',
        'type' => 'attachment',
        'body' => [
            'query' => [
                'match' => [
                    'content' => 'dhaka'
                ]
            ],
        ]
    ];

    $response = $client->search($params);
    print_r($response['hits']['hits']);
}

Result ::

Array( )

Apologies, I messed up something. Would you please help me so that every one can get the best answer ?

Selim Reza
  • 683
  • 1
  • 11
  • 31
  • Can you show the content of the document `/ingest_index/attachment/2` after you've indexed it? – Val Jan 23 '17 at 05:34

0 Answers0