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

How can you tell if Enhanced Search is working?

Discussion in 'Enhanced Search Support' started by wardsweb, Nov 2, 2015.

  1. wardsweb

    wardsweb Member

    Elasticsearch and Enhanced Search are installed and enabled. How can I tell if it is actually working and not just the regular search running?
     
  2. Brogan

    Brogan XenForo Moderator Staff Member

    If you have set the option to enable Elasticsearch and search results are being returned, then it is working.

    You can truncate the xf_search_index table, as it is no longer used.
     
  3. Mr Lucky

    Mr Lucky Well-Known Member

    In addition to what brogan said, for extra peace of mind try searching for small (e.g. 3 letter) words.
     
  4. RoldanLT

    RoldanLT Well-Known Member

    Or access: /admin.php?elasticsearch/
     
  5. wardsweb

    wardsweb Member

    When I tried a search, it returns an error.

    Server Error
    Object of class stdClass could not be converted to string

    1. XenForo_Application::handlePhpError() in XenES/Search/SourceHandler/ElasticSearch.php at line 845
    2. XenES_Search_SourceHandler_ElasticSearch->_logSearchResponseError() in XenES/Search/SourceHandler/ElasticSearch.php at line 305
    3. XenES_Search_SourceHandler_ElasticSearch->executeSearch() in XenForo/Search/SourceHandler/Abstract.php at line 115
    4. XenForo_Search_SourceHandler_Abstract->searchGeneral() in XenForo/Search/Searcher.php at line 79
    5. XenForo_Search_Searcher->searchGeneral() in XenForo/ControllerPublic/Search.php at line 246
    6. XenForo_ControllerPublic_Search->actionSearch() in XenES/Proxy/ControllerSearch.php at line 30
    7. XenES_Proxy_ControllerSearch->actionSearch() in XenForo/FrontController.php at line 351
    8. XenForo_FrontController->dispatch() in XenForo/FrontController.php at line 134
    9. XenForo_FrontController->run() in /chroot/home/html/forums/index.php at line 13
    Audiokarma Home Audio Stereo Discussion Forums
    Home
     
  6. Brogan

    Brogan XenForo Moderator Staff Member

  7. wardsweb

    wardsweb Member

    I opened the diff file in notepad and see this code. I am not a programmer, so I need a little clarification. At lines 214 / 215, I will find the else statement (first four lines of code). I then add the one line of code with the "+". This is followed by four more lines of code, I do nothing with. I proceed to remove and add lines marked by the plus and minus signs.

    Code:
    @@ -214,15 +214,36 @@
                         else
                         {
                             $script = "_score / pow(2.0f, min(10.0f * halflife, abs(now - doc['date'].value + .0f)) / (halflife + .0f))";
                         }
    +                    $scriptType = 'inline';
                     }
                     else
                     {
                         $script = 'xf-date-weighted';
    -                }
    -
    -                if ($version >= '1.0')
    +                    $scriptType = 'file';
    +                }
    +
    +                if ($version >= '2.0')
    +                {
    +                    $dsl['query'] = array(
    +                        'function_score' => array(
    +                            'boost_mode' => 'replace',
    +                            'query' => $dsl['query'],
    +                            'script_score' => array(
    +                                'script' => array(
    +                                    'params' => array(
    +                                        'now' => XenForo_Application::$time,
    +                                        'halflife' => 86400 * $weightedRelevance['halfLifeDays']
    +                                    ),
    +                                    'lang' => $language,
    +                                    $scriptType => $script
    +                                )
    +                            )
    +                        )
    +                    );
    +                }
    +                else if ($version >= '1.0')
                     {
                         $dsl['query'] = array(
                             'function_score' => array(
                                 'boost_mode' => 'replace',
     
  8. Brogan

    Brogan XenForo Moderator Staff Member

    The - indicates lines which must be removed from the original file, the + indicates lines which must be added.
     
  9. wardsweb

    wardsweb Member

    Looks like I may have done something wrong. I edited the file and now get a HTTP 500 Internal Error.
     
  10. Brogan

    Brogan XenForo Moderator Staff Member

    You can restore the original file from the .zip archive if you think you've edited it incorrectly.
     
  11. wardsweb

    wardsweb Member

    I have the original I saved before uploading the edited version. I will check the edit and see if I'm off a space or digit or something.
     
  12. Brogan

    Brogan XenForo Moderator Staff Member

    Make sure you use an editor such as Notepad++ and save it as UTF-8 without BOM.
     
  13. wardsweb

    wardsweb Member

    I used Dreamweaver. I haven't had an issue with PHP files with it before.
     
  14. wardsweb

    wardsweb Member

    I found a "+" that got copied over when editing the file. Now when I enable the enhanced search and tried a search, it returns the forum title with an error "Audiokarma Home Audio Stereo Discussion Forums - Error"

    The server log has this:

    Code:
    
    Error Info
    
    XenForo_Exception: Elasticsearch error: {"root_cause":[{"type":"script_exception","reason":"scripts of type [inline], operation [search] and lang [groovy] are disabled"}],"type":"search_phase_execution_exception","reason":"all shards failed","phase":"query","grouped":true,"failed_shards":[{"shard":0,"index":"ak_audiokarma","node":"NUZDtjtVTCuEkWo66xgMxw","reason":{"type":"query_parsing_exception","reason":"script_score the script could not be loaded","index":"ak_audiokarma","line":1,"col":328,"caused_by":{"type":"script_exception","reason":"scripts of type [inline], operation [search] and lang [groovy] are disabled"}}}]} - library/XenES/Search/SourceHandler/ElasticSearch.php:871
    Generated By: Wardsweb, 4 minutes ago
    
    Stack Trace
    
    #0 /chroot/home/ak/audiokarma.org/html/forums/library/XenES/Search/SourceHandler/ElasticSearch.php(325): XenES_Search_SourceHandler_ElasticSearch->_logSearchResponseError(Object(stdClass), true)
    #1 /chroot/home/ak/audiokarma.org/html/forums/library/XenForo/Search/SourceHandler/Abstract.php(115): XenES_Search_SourceHandler_ElasticSearch->executeSearch('wardsweb', true, Array, Array, false, '200')
    #2 /chroot/home/ak/audiokarma.org/html/forums/library/XenForo/Search/Searcher.php(79): XenForo_Search_SourceHandler_Abstract->searchGeneral('wardsweb', Array, 'relevance', '200')
    #3 /chroot/home/ak/audiokarma.org/html/forums/library/XenForo/ControllerPublic/Search.php(246): XenForo_Search_Searcher->searchGeneral('wardsweb', Array, 'relevance')
    #4 /chroot/home/ak/audiokarma.org/html/forums/library/XenES/Proxy/ControllerSearch.php(30): XenForo_ControllerPublic_Search->actionSearch()
    #5 /chroot/home/ak/audiokarma.org/html/forums/library/XenForo/FrontController.php(351): XenES_Proxy_ControllerSearch->actionSearch()
    #6 /chroot/home/ak/audiokarma.org/html/forums/library/XenForo/FrontController.php(134): XenForo_FrontController->dispatch(Object(XenForo_RouteMatch))
    #7 /chroot/home/ak/audiokarma.org/html/forums/index.php(13): XenForo_FrontController->run()
    #8 {main}
    
    Request State
    
    array(3) {
      ["url"] => string(52) "http://audiokarma.org/forums/index.php?search/search"
      ["_GET"] => array(1) {
        ["search/search"] => string(0) ""
      }
      ["_POST"] => array(5) {
        ["keywords"] => string(8) "wardsweb"
        ["title_only"] => string(1) "1"
        ["users"] => string(0) ""
        ["date"] => string(0) ""
        ["_xfToken"] => string(8) "********"
      }
    }
    
    
    Delete... Close
    
     
  15. MattW

    MattW Well-Known Member

    https://xenforo.com/community/threads/elasticsearch-2-0-error.107641/
     
  16. wardsweb

    wardsweb Member

  17. MattW

    MattW Well-Known Member

    Yes, have a look at the other messages in that thread. You'll see the same error you are getting now, with the fix I posted.
     
  18. wardsweb

    wardsweb Member

    Having done the file edit, I only need to uncheck the weighted box?

    edit: I have answered my own question by unchecking the box and doing a search. It is now working.

    Thanks everyone!
     
    MattW likes this.
  19. wardsweb

    wardsweb Member

    So now that it is working, do I need to rebuild the search index? When checking delete the ES index is says it forces a rebuild with optimization. Does this happen automatically or after saving, do I then rebuild the cache?
     
  20. Brogan

    Brogan XenForo Moderator Staff Member

Share This Page