tag:support.flying-sphinx.com,2011-01-05:/discussions/problems/34-indexing-errors Flying Sphinx: Discussion 2016-08-11T01:37:18Z tag:support.flying-sphinx.com,2011-01-05:Comment/9332639 2011-08-16T12:00:07Z 2011-08-16T12:00:10Z Indexing errors <div><p>Ah, some of these things might be related to switching from mysql to postgres...</p></div> Nico tag:support.flying-sphinx.com,2011-01-05:Comment/9332639 2011-08-16T12:02:58Z 2011-08-16T12:02:58Z Indexing errors <div><p>Yup - if you get stuck with it, I'm happy to provide suggestions - though sharing your define_index block will certainly help with that :)</p></div> Pat Allan tag:support.flying-sphinx.com,2011-01-05:Comment/9332639 2011-08-16T13:17:44Z 2011-08-16T13:17:46Z Indexing errors <div><p>Ah, I see, I need to add some group_bys... trying that now ;-)</p></div> Nico tag:support.flying-sphinx.com,2011-01-05:Comment/9332639 2011-08-16T13:30:56Z 2011-08-16T13:30:57Z Indexing errors <div><p>Okay, all works now, except this line in the job model's index:</p> <p>has 'CRC32(country_string)', :as =&gt; :country_for_filtering, :type =&gt; :integer</p> <p>'indexing index 'job_core'... ERROR: index 'job_core': sql_range_query: ERROR: function crc32(character varying) does not exist<br> LINE 1: ..."name", '') AS "job_name_sort", 1 AS "activated", CRC32(coun...</p> <pre> <code> ^</code> </pre> <p>HINT: No function matches the given name and argument types. You might need to add explicit type casts.<br> (DSN=pgsql://lisuxygdfr:***@127.0.0.1:10323/lisuxygdfr). total 0 docs, 0 bytes<br> total 0.056 sec, 0 bytes/sec, 0.00 docs/sec<br> indexing index 'job_delta'...<br> ERROR: index 'job_delta': sql_range_query: ERROR: function crc32(character varying) does not exist<br> LINE 1: ..."name", '') AS "job_name_sort", 1 AS "activated", CRC32(coun...</p> <pre> <code> ^</code> </pre> <p>HINT: No function matches the given name and argument types. You might need to add explicit type casts.<br> (DSN=pgsql://lisuxygdfr:***@127.0.0.1:10323/lisuxygdfr).'</p></div> Nico tag:support.flying-sphinx.com,2011-01-05:Comment/9332639 2011-08-16T13:32:47Z 2011-08-16T13:32:48Z Indexing errors <div><p>Hmm I will have to find a workaround for that crc32 thing. However, when I take it out,<br> I get the following error when searching with thinking sphinx:</p> <p>Sphinx Sphinx Daemon returned error: no such filter attribute 'user_id'</p> <p>Here is the user's index definition:</p> <p>define_index do</p> <pre> <code>indexes(vorname, :as =&gt; :first_name, :sortable =&gt; true) indexes(tags.name, :as =&gt; :tags) indexes(company.name, :as =&gt; :company) indexes(job.name, :as =&gt; :job) # only index last name if privacy is turned off indexes("CASE WHEN privacy_name = 0 THEN '' ELSE nachname END", :as =&gt; :last_name, :sortable =&gt; true) # Geo stuff. Sphinx expects radians, we store degrees thus the conversion has('RADIANS(users.lat)', :as =&gt; :lat, :type =&gt; :float) has('RADIANS(users.lng)', :as =&gt; :lng, :type =&gt; :float) # Index user id so we can exclude myself from search has(:id, :as =&gt; :user_id) # make sure we only hit activated users in searches (this allows for filtering) has('1', :as =&gt; :activated, :type =&gt; :integer) has "CASE WHEN users.country = 'Deutschland' THEN '0' ELSE CASE WHEN users.country = 'Schweiz' THEN '1' ELSE '2' END END", :as =&gt; :country_for_order_de, :type =&gt; :integer has "CASE WHEN users.country = 'Schweiz' THEN '0' ELSE CASE WHEN users.country = 'Deutschland' THEN '1' ELSE '2' END END", :as =&gt; :country_for_order_ch, :type =&gt; :integer has "CASE WHEN users.country = '&Ouml;sterreich' THEN '0' ELSE CASE WHEN users.country = 'Deutschland' THEN '1' ELSE '2' END END", :as =&gt; :country_for_order_at, :type =&gt; :integer group_by "users.privacy_name", "users.nachname", "users.lat", "users.lng", 'users.country' # settings if Rails.env.production? or Rails.env.staging? set_property :delta =&gt; FlyingSphinx::DelayedDelta end set_property :latitude_attr =&gt; 'lat' set_property :longitue_attr =&gt; 'lng' set_property :enable_star =&gt; true set_property :min_infix_len =&gt; 1 set_property :morphology =&gt; 'none'</code> </pre> <p>end</p></div> Nico tag:support.flying-sphinx.com,2011-01-05:Comment/9332639 2011-08-16T16:09:44Z 2011-08-16T16:09:46Z Indexing errors <div><p>Okay, fixed the last issue. Instead of using crc32 I simply assign an int to each country for filtering.</p></div> Nico tag:support.flying-sphinx.com,2011-01-05:Comment/9332639 2011-08-16T16:10:22Z 2011-08-16T16:10:24Z Indexing errors <div><p>Can you close the discussion? I can't.</p></div> Nico tag:support.flying-sphinx.com,2011-01-05:Comment/9332639 2011-08-17T06:03:24Z 2011-08-17T06:03:24Z Indexing errors <div><p>Consider it closed - great to hear you got it all sorted.</p></div> Pat Allan