[Beta] Sphinx search for phpBB 1.0.beta2

A place for MOD Authors to post and receive feedback on MODs still in development. No MODs within this forum should be used within a live environment!
Ideas Centre
User avatar
aurquiel
Registered User
Posts: 243
Joined: Fri May 15, 2009 1:45 am

Re: [Beta] Sphinx search for phpBB 1.0.beta2

Post by aurquiel » Sun Jan 29, 2012 9:06 pm

dont work for me nothing found when a user search

Paul
Infrastructure Team Leader
Infrastructure Team Leader
Posts: 25230
Joined: Sat Dec 04, 2004 3:44 pm
Location: The netherlands.
Name: Paul Sohier
Contact:

Re: [Beta] Sphinx search for phpBB 1.0.beta2

Post by Paul » Mon Jan 30, 2012 10:18 am

Holger wrote:Does anyone have a running demo?

And: does this search support/use the phpBB-auth system (hidden forums, different access settings)?
It is being used here at phpBB.com.
Knock knock
Race condition
Who's there?

My BlogMy Photosmy phpBB Extensionscustom phpBB work & Development

ilantipov
Registered User
Posts: 3
Joined: Tue May 03, 2011 6:43 am

Re: [Beta] Sphinx search for phpBB 1.0.beta2

Post by ilantipov » Tue Mar 27, 2012 9:52 am

Sumitted a patch to figvam https://github.com/figvam/sphinx-for-phpbb/pull/1 That fixes search by author name that matches a preveousely deleted user that had posts.
It's my first experience with github. Hope figvam will commit it. Thanks.

User avatar
Kamahl19
Registered User
Posts: 1598
Joined: Tue Nov 06, 2007 3:33 pm
Location: Slovakia
Name: Martin
Contact:

Re: [Beta] Sphinx search for phpBB 1.0.beta2

Post by Kamahl19 » Thu May 10, 2012 5:05 pm

Hi,

is this working with phpBB 3.0.8-3.0.10 and Sphinx 2.0.4 ?

What vrsion should I download? This one https://github.com/figvam/sphinx-for-phpbb or this https://github.com/phpbb/sphinx-for-phpbb ?

parsim
Registered User
Posts: 30
Joined: Fri Jan 15, 2010 10:29 pm

Re: [Beta] Sphinx search for phpBB 1.0.beta2

Post by parsim » Thu May 10, 2012 11:08 pm

Kamahl19 wrote:Hi,

is this working with phpBB 3.0.8-3.0.10 and Sphinx 2.0.4 ?

What vrsion should I download? This one https://github.com/figvam/sphinx-for-phpbb or this https://github.com/phpbb/sphinx-for-phpbb ?
It's worked for me on every version of phpBB and Sphinx I've ever tried. Currently working with phpBB 3.0.10 and Sphinx 2.0.4.

The figvam one is a little better, since it's been updated more recently and has a few minor fixes. But there really isn't much practical difference.

User avatar
Kamahl19
Registered User
Posts: 1598
Joined: Tue Nov 06, 2007 3:33 pm
Location: Slovakia
Name: Martin
Contact:

Re: [Beta] Sphinx search for phpBB 1.0.beta2

Post by Kamahl19 » Fri May 11, 2012 12:05 am

Okey I will download the forked version. Thanks for answer

baller1234
Registered User
Posts: 129
Joined: Sat May 29, 2010 9:43 am

Re: [Beta] Sphinx search for phpBB 1.0.beta2

Post by baller1234 » Fri May 11, 2012 9:22 pm

For everyone who has zero results and no author search do this: (thanks to pandora and thenickdude. But for some hard to read the code edits.) btw, this works fine with sphinx 2.0.4 and phpbb 3.10

EDIT: Just found out that you only have 1 page with results. The rest of the pages is the same as the first. Maby someone knows how to fix this. This is for author search but also for normal search.

FIND:

Code: Select all

require($phpbb_root_path . "includes/sphinxapi-0.9.8." . $phpEx);
AFTER ADD:

Code: Select all

include_once($phpbb_root_path . 'includes/search/search.' . $phpEx);
FIND:

Code: Select all

class fulltext_sphinx
REPLACE:

Code: Select all

class fulltext_sphinx extends search_backend
FIND:

Code: Select all

		// No keywords? No posts.
		if (!strlen($this->search_query) && !sizeof($author_ary))
		{
			return false;
		}
ADD AFTER:

Code: Select all

// (c) Pandora
             // generate a search_key from all the options to identify the results
             $search_key = md5(implode('#', array(
                 $this->search_query,
                 $type,
                 $fields,
                 $terms,
                 $sort_days,
                 $sort_key,
                 $topic_id,
                 implode(',', $ex_fid_ary),
                 implode(',', $m_approve_fid_ary),
                 implode(',', $author_ary)
             )));
    
             // try reading the results from cache
             $result_count = 0;
             if (false && $this->obtain_ids($search_key, $result_count, $id_ary, $start, $per_page, $sort_dir) == SEARCH_RESULT_IN_CACHE)
             {
                 return $result_count;
         }

// (c) Pandora

FIND:

Code: Select all

          $result = $this->sphinx->Query($search_query_prefix . str_replace('"', '"', $this->search_query), $this->indexes);

          // could be connection to localhost:3312 failed (errno=111, msg=Connection refused) during rotate, retry if so
          $retries = CONNECT_RETRIES;
          while (!$result && (strpos($this->sphinx->_error, "errno=111,") !== false) && $retries--)
          {
             usleep(CONNECT_WAIT_TIME);
             $result = $this->sphinx->Query($search_query_prefix . str_replace('"', '"', $this->search_query), $this->indexes);
          }
REPLACE:

Code: Select all

          $result = $this->sphinx->Query($search_query_prefix . $this->sphinx->EscapeString(str_replace('"', '"', $this->search_query)), $this->indexes);

          // could be connection to localhost:3312 failed (errno=111, msg=Connection refused) during rotate, retry if so
          $retries = CONNECT_RETRIES;
          while (!$result && (strpos($this->sphinx->_error, "errno=111,") !== false) && $retries--)
          {
             usleep(CONNECT_WAIT_TIME);
             $result = $this->sphinx->Query($search_query_prefix . $this->sphinx->EscapeString(str_replace('"', '"', $this->search_query)), $this->indexes);
          }


FIND:

Code: Select all

$result_count = $result['total_found'];
ADD AFTER:

Code: Select all

// store the ids, from start on then delete anything that isn't on the current page because we only need ids for one page
$this->save_ids($search_key, $this->search_query, $author_ary, $result_count, $id_ary, $start, $sort_dir);
Last edited by baller1234 on Sat May 12, 2012 2:47 pm, edited 3 times in total.

User avatar
4_seven
I've Been Banned!
Posts: 5155
Joined: Wed Apr 30, 2008 1:41 am

Re: [Beta] Sphinx search for phpBB 1.0.beta2

Post by 4_seven » Fri May 11, 2012 10:57 pm

perfect. big thanks for working this out.
Current Mods | Mod Base | php(BB) programming | No help via PM

baller1234
Registered User
Posts: 129
Joined: Sat May 29, 2010 9:43 am

Re: [Beta] Sphinx search for phpBB 1.0.beta2

Post by baller1234 » Sat May 12, 2012 11:09 am

HELP PLEASE

still there seems to be a problem. With the above code change you only have one page of results. Does not matter if its a author post or just a search.. If you have 30 pages of results, they are all the same as the first.
Only 1 page is cached..

User avatar
4_seven
I've Been Banned!
Posts: 5155
Joined: Wed Apr 30, 2008 1:41 am

Re: [Beta] Sphinx search for phpBB 1.0.beta2

Post by 4_seven » Sat May 12, 2012 8:42 pm

Oops, cheered too soon.

try

Code: Select all

include($phpbb_root_path . 'includes/search/search.' . $phpEx);
instead of

Code: Select all

include_once($phpbb_root_path . 'includes/search/search.' . $phpEx);
and/or remove the cache thing testwise

Code: Select all

             // try reading the results from cache
             $result_count = 0;
             if (false && $this->obtain_ids($search_key, $result_count, $id_ary, $start, $per_page, $sort_dir) == SEARCH_RESULT_IN_CACHE)
             {
                 return $result_count;
         }
Current Mods | Mod Base | php(BB) programming | No help via PM

baller1234
Registered User
Posts: 129
Joined: Sat May 29, 2010 9:43 am

Re: [Beta] Sphinx search for phpBB 1.0.beta2

Post by baller1234 » Sat May 12, 2012 8:55 pm

Thx for your help 4_seven.. But it doesnt work :(

I replaced the include line and removed the cache thing.. Search still works but still the same problem.

this line? store the ids, from start on then delete anything that isn't on the current page because we only need ids for one page

maby?

Code: Select all

         // store the ids, from start on then delete anything that isn't on the current page because we only need ids for one page
          $this->save_ids($search_key, $this->search_query, $author_ary, $result_count, $id_ary, $start, $sort_dir, $per_page);

User avatar
4_seven
I've Been Banned!
Posts: 5155
Joined: Wed Apr 30, 2008 1:41 am

Re: [Beta] Sphinx search for phpBB 1.0.beta2

Post by 4_seven » Sat May 12, 2012 9:05 pm

hm i dont know the code around this. in which file is it?
Current Mods | Mod Base | php(BB) programming | No help via PM

baller1234
Registered User
Posts: 129
Joined: Sat May 29, 2010 9:43 am

Re: [Beta] Sphinx search for phpBB 1.0.beta2

Post by baller1234 » Sat May 12, 2012 9:09 pm

http://www.phpbb.com/community/viewtopi ... #p12853523

code change from pandora when you get zero results..

in file fulltext_sphinx.php

User avatar
4_seven
I've Been Banned!
Posts: 5155
Joined: Wed Apr 30, 2008 1:41 am

Re: [Beta] Sphinx search for phpBB 1.0.beta2

Post by 4_seven » Sat May 12, 2012 9:17 pm

unfortunately Ciao121 never give any feedback
http://www.phpbb.com/community/viewtopi ... #p12874244
these are the things, i love. i think, we better wait for naderman.
i should have it live installed to fix. otherwise its a lottery.
and no time to install the whole thing, only to figure out this stuff.
Current Mods | Mod Base | php(BB) programming | No help via PM

baller1234
Registered User
Posts: 129
Joined: Sat May 29, 2010 9:43 am

Re: [Beta] Sphinx search for phpBB 1.0.beta2

Post by baller1234 » Sun May 13, 2012 5:33 am

I fixed it myself.. I started over again and replaced the fulltext_sphinx file with the figvam release and now only did the edit of thenickdude:

FIND:

Code: Select all

          $result = $this->sphinx->Query($search_query_prefix . str_replace('"', '"', $this->search_query), $this->indexes);

          // could be connection to localhost:3312 failed (errno=111, msg=Connection refused) during rotate, retry if so
          $retries = CONNECT_RETRIES;
          while (!$result && (strpos($this->sphinx->_error, "errno=111,") !== false) && $retries--)
          {
             usleep(CONNECT_WAIT_TIME);
             $result = $this->sphinx->Query($search_query_prefix . str_replace('"', '"', $this->search_query), $this->indexes);
          }
REPLACE:

Code: Select all

          $result = $this->sphinx->Query($search_query_prefix . $this->sphinx->EscapeString(str_replace('"', '"', $this->search_query)), $this->indexes);

          // could be connection to localhost:3312 failed (errno=111, msg=Connection refused) during rotate, retry if so
          $retries = CONNECT_RETRIES;
          while (!$result && (strpos($this->sphinx->_error, "errno=111,") !== false) && $retries--)
          {
             usleep(CONNECT_WAIT_TIME);
             $result = $this->sphinx->Query($search_query_prefix . $this->sphinx->EscapeString(str_replace('"', '"', $this->search_query)), $this->indexes);
          }
Now all seems to work ok!! Verry weird..

Locked

Return to “[3.0.x] MODs in Development”