Fixed Elasticsearch 1.0 backwards compatibility breaks - stemming, optimize mappings

Mike

XenForo developer
Staff member
Elasticsearch 1.0 changed the API relating to the mappings and settings endpoints. This means that in the Elasticsearch Setup page in the control panel, mapping optimization and stemming configuration changes do not appear to be applied. However, they are being applied; they are just not being read back correctly.

The fix for this issue (visual appearance only) is attached as a unified diff file. If you don't upgrade to ES 1.0, you will not run into this issue.
 

Attachments

Only Mike and Kier have access. Mike has provided you with a patch file that will allow you to make the changes necessary yourself.
 
It's really not difficult.

Find:

PHP:
        if (isset($results->$indexName))

Replace with:

PHP:
        if (isset($results->$indexName->mappings))
        {
            // elasticsearch 1.0 format
            return $results->$indexName->mappings;
        }
        else if (isset($results->$indexName))


Then find:

PHP:
            $type = isset($settings->{'index.analysis.analyzer.default.type'})
                ? $settings->{'index.analysis.analyzer.default.type'}
                : 'standard';
            $language = isset($settings->{'index.analysis.analyzer.default.language'})
                ? $settings->{'index.analysis.analyzer.default.language'}
                : 'English';

And replace with:

PHP:
            if (isset($settings->{'index.analysis.analyzer.default.type'}))
            {
                $type = $settings->{'index.analysis.analyzer.default.type'};
            }
            else if (isset($settings->index->analysis->analyzer->default->type))
            {
                $type = $settings->index->analysis->analyzer->default->type;
            }
            else
            {
                $type = 'standard';
            }

            if (isset($settings->{'index.analysis.analyzer.default.language'}))
            {
                $language = $settings->{'index.analysis.analyzer.default.language'};
            }
            else if (isset($settings->index->analysis->analyzer->default->language))
            {
                $language = $settings->index->analysis->analyzer->default->language;
            }
            else
            {
                $language = 'English';
            }
 
Well the diff file shows you which lines preceed it.

Find:
PHP:
        $indexName = XenES_Api::getInstance()->getIndex();

        $results = XenES_Api::getMappings($indexName);
        if (isset($results->$indexName))

Replace:
PHP:
        $indexName = XenES_Api::getInstance()->getIndex();

        $results = XenES_Api::getMappings($indexName);
        if (isset($results->$indexName->mappings))
        {
            // elasticsearch 1.0 format
            return $results->$indexName->mappings;
        }
        else if (isset($results->$indexName))
 
Top Bottom