Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Paris Holley

    (@parisholley)

    The plugin doesn’t support this as it stands. Here is a forum post that describes how to use Elastica and set that property. Feel free to open an issue on github, or attempt to modify Indexer.php to incorporate the changes you need and submit a pull request.

    Plugin Author Paris Holley

    (@parisholley)

    Here is a quick solution to add the not_analyzed index to elasticsearch via wordpress. I’m doing it here on the init to make sure it is taken into consideration. This is just an example, you can add some conditions to make it better performance-wise :

    if ( is_plugin_active('fantastic-elasticsearch/elasticsearch.php') ) :
    	add_action( 'init', 'prepare_mapping' );
    endif;
    
    function prepare_mapping()
    {
    	$index_exists = elasticsearch\Api::option('server_index');
    	if ( $index_exists ) {
    		try {
    			$elasticaType =  elasticsearch\Api::index(true)->getType('post');
    			$mapping_data = $elasticaType->getMapping();
    			$mapping_data = $mapping_data['post']['properties'];
    
    			$mapping_data['your_field']['type'] = 'string';
    			$mapping_data['your_field']['index'] = 'not_analyzed';
    
    			$mapping = new \Elastica_Type_Mapping();
    			$mapping->setType($elasticaType);
    			$mapping->setProperties($mapping_data);
    
    			$mapping->send();
    		} catch(Exception $e) {
    			//Do nothing, just make sure the error is not showing
    		}
    	}
    }
    Plugin Author Paris Holley

    (@parisholley)

    Thanks for looking into this! I have created an issue on github for it:

    https://github.com/parisholley/wordpress-fantastic-elasticsearch/issues/23

    If you are interested, I have a 2.0.0-wip branch in the works that has some integration tests with elasticsearch if you wish to update the code and write some tests that verify it works properly. Otherwise, I will consider adding it in after I get 2.0.0 released

    Plugin Author Paris Holley

    (@parisholley)

    this has been fixed in the 2.0.0 branch

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘not_analyzed’ is closed to new replies.