How can you tell if Enhanced Search is working?

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?
 

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.
 

Mr Lucky

Well-known 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?
In addition to what brogan said, for extra peace of mind try searching for small (e.g. 3 letter) words.
 

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
 

wardsweb

Member
Are you running elasticsearch 2.0?

There's a fix here for that: https://xenforo.com/community/threads/elasticsearch-2-0-error.107641/
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',
 

Brogan

XenForo moderator
Staff member
The - indicates lines which must be removed from the original file, the + indicates lines which must be added.
 

wardsweb

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

Brogan

XenForo moderator
Staff member
You can restore the original file from the .zip archive if you think you've edited it incorrectly.
 

wardsweb

Member
You can restore the original file from the .zip archive if you think you've edited it incorrectly.
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.
 

Brogan

XenForo moderator
Staff member
Make sure you use an editor such as Notepad++ and save it as UTF-8 without BOM.
 

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
 

MattW

Well-known 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
https://xenforo.com/community/threads/elasticsearch-2-0-error.107641/
 

MattW

Well-known member
Thanks but my error is after I manually edited the file using Mike's ESFIX.diff Is there something else I'm missing?
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.
 

wardsweb

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

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?
 
Top