1. 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

Discussion in 'Enhanced Search Resolved Bugs' started by Mike, Feb 14, 2014.

  1. Mike

    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.
     

    Attached Files:

    seojoseph, p4guru, thedude and 2 others like this.
  2. RoldanLT

    RoldanLT Well-Known Member

    I'm the one reported this :D
    Thanks Mike !
     
  3. RoldanLT

    RoldanLT Well-Known Member

    @Mike Could you please upload here the updated library/XenES/Model/Elasticsearch.php file please?
    Thanks !
     
  4. BamaStangGuy

    BamaStangGuy Well-Known Member

    What do I do with that file?
     
  5. Mike

    Mike XenForo Developer Staff Member

    Any lines that start with "-" are removed, any that start with "+" are added. Other lines give you the context of how to find it. (You can also apply the changes programmatically with "patch": https://drupal.org/patch/apply)
     
    BamaStangGuy likes this.
  6. CyclingTribe

    CyclingTribe Well-Known Member

    Thanks for the fix Mike - I noticed this after upgrading ES and XFES the other night. (y)
     
  7. RoldanLT

    RoldanLT Well-Known Member

    Anyone? :confused:
     
  8. Jeremy

    Jeremy XenForo Moderator Staff Member

    Only Mike and Kier have access. Mike has provided you with a patch file that will allow you to make the changes necessary yourself.
     
    RoldanLT likes this.
  9. Chris D

    Chris D XenForo Developer Staff Member

    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';
                }
     
  10. RoldanLT

    RoldanLT Well-Known Member

    But there are two instances of if (isset($results->$indexName)).
     
  11. Chris D

    Chris D XenForo Developer Staff Member

    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))
     
    p4guru and RoldanLT like this.
  12. RoldanLT

    RoldanLT Well-Known Member

    Done, thanks.
    Change line #21 and #150.
     
  13. RoldanLT

    RoldanLT Well-Known Member

    I hope this is correct :)
    upload_2014-2-19_6-6-26.png

    upload_2014-2-19_6-6-59.png
     

Share This Page