• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

Fixed Elasticsearch 1.0 backwards compatibility breaks - stemming, optimize mappings

Mike

XenForo developer
Staff member
#1
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

Chris D

XenForo developer
Staff member
#9
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';
            }
 

Chris D

XenForo developer
Staff member
#11
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))