parisholley / wordpress-fantastic-elasticsearch

Improve wordpress search performance/accuracy and enable faceted search by leveraging an ElasticSearch server.
MIT License
162 stars 64 forks source link

Feed elasticsearch with document attachments #118

Open ocReaper opened 9 years ago

ocReaper commented 9 years ago

It could be usefull if we could search in document attachments like pdfs, epubs. I'm just brainstorming but there is a hook for attachment uploads what you could use.

function add_attachment_to_elastic($results) {
    if( $results['type'] === 'application/pdf' ) {
        $filename = $results[ 'file' ];
        $url = $results[ 'url' ];

        // add attachment to elastic
        // Elastica\Document addFile($key, $filepath, $mimeType = '')
    }
}

add_action('add_attachment', 'add_attachment_to_elastic');
codelogn commented 9 years ago

Last week, I customized the plugin to support search in documents and posts attachments. I just needed to install mapper type attachment plugin and add similar code.

ocReaper commented 9 years ago

Thank you for the continuous improvement of the plugin! It's really helpful for us! Me and the company I work for are looking forward to the next release! :smile: Keep up the good work! :+1: