Looks like you've hit one thing I've not mentioned - but I should have: because you're dealing with methods, not columns, it's not possible for Thinking Sphinx to discern attribute types automatically. So, you'll need to specify the type:
has image_origin_id, :as => :origin, :type => :integer
Give that a spin, let us know how you go.
Cheers
--
Pat
On 14/01/2013, at 10:15 PM, govinda....@googlemail.com wrote:
> Hello guys,
>
> after the announcement here https://github.com/pat/thinking-sphinx/issues/186 that there is some support for realtime indexes I gave it shot and tried to port my existing (and working) thinking_sphinx v2 indexes and tried to port them to the new v3 syntax...
>
> ThinkingSphinx::Index.define :image, :with => :real_time do
> # indexes assoc(:file)
> indexes file_width
> indexes file_height
> indexes file_colorspace
> indexes file_content_type, :as => :file_type
> indexes file_resolution
> indexes file_depth
> indexes description
> indexes category
> indexes tags
> indexes campaigns
> indexes image_type.name, :as => :image_type_name
> # has "CRC32(file_chromaticity)", :as => :chromaticity, :type => :integer
> # has "CRC32(file_aspect_ratio)", :as => :aspect_ratio, :type => :integer
> has image_origin_id, :as => :origin
> # has image_licencetype_id, :as => :licencetype
> # has image_type_id, :as => :image_type
> # has client_id
> # has user_id
> # has created_at
> # has updated_at
> # has status
> end
>
> When I do a "rake ts:generate" I get the following error:
>
> rake aborted!
> Unknown attribute type ''
>
> Does anybody know how I have to change my indexes to get them to play nicely with sphinx3?
> I am using the edge branch with Rails 3.2.9, Ruby 1.9.3 and sphinx 2.0.6.
>
> Cheers, Govinda
>
> --
> You received this message because you are subscribed to the Google Groups "Thinking Sphinx" group.
> To view this discussion on the web visit https://groups.google.com/d/msg/thinking-sphinx/-/alt4z1a6To8J.
> To post to this group, send email to thinkin...@googlegroups.com.
> To unsubscribe from this group, send email to thinking-sphi...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/thinking-sphinx?hl=en.
--
Pat
> --
> You received this message because you are subscribed to the Google Groups "Thinking Sphinx" group.
> To view this discussion on the web visit https://groups.google.com/d/msg/thinking-sphinx/-/QIwa-lt68y4J.
--
Pat
> --
> You received this message because you are subscribed to the Google Groups "Thinking Sphinx" group.
> To view this discussion on the web visit https://groups.google.com/d/msg/thinking-sphinx/-/dEA7kfrcuWgJ.
> and I also have a problem with the following index declarations:
>
> has "CRC32(file_chromaticity)", :as => :chromaticity, :type => :integer
>
> The error I get is:
> Generating index files for image_core
> rake aborted!
> undefined method `__name' for "CRC32(file_chromaticity)":String
> -e:1:in `<main>'
> Tasks: TOP => ts:generate
> (See full trace by running task with --trace)
Firstly - you're using a SQL snippet, and real-time indices don't touch the database - in this situation, Thinking Sphinx communicates directly between your Rails models and Sphinx. Also, there's no support in Thinking Sphinx v3 for CRC32 encoding… mind you, you could add it itself.
Perhaps something like this within the model (and add a "require 'zlib'" at the top of your model):
def file_chromaticity_to_crc32
Zlib.crc32 file_chromaticity
end
And then in your index definition, you can reference that method:
has file_chromaticity_to_crc32, :as => :chromaticity, :type => :integer
> and the line
>
> indexes assoc(:file)
>
> produces the following error:
> Generating index files for image_core
> rake aborted!
> undefined method `assoc' for #<Image:0x007f979ffccb30>
> -e:1:in `<main>'
> Tasks: TOP => ts:generate
> (See full trace by running task with --trace)
You don't need this line - because you're dealing with Ruby, not SQL, there's no need to specify joins.
Cheers
--
Pat
--
Pat
> --
> You received this message because you are subscribed to the Google Groups "Thinking Sphinx" group.
> To view this discussion on the web visit https://groups.google.com/d/msg/thinking-sphinx/-/EK7lcZXrOMIJ.
And sorry, I wasn't clear with that comment about the logs. I meant the Rails logs.
Cheers
--
Pat
> To view this discussion on the web visit https://groups.google.com/d/msg/thinking-sphinx/-/7-gJ17EdG-gJ.
SELECT * FROM image_core WHERE MATCH('sphinx @sphinx_internal_class_name (Image)');
That's closer to what Thinking Sphinx will be sending through.
> To view this discussion on the web visit https://groups.google.com/d/msg/thinking-sphinx/-/h_lZ9cIn7J8J.
has status, :as => :image_status, :type => :integer
> --
> You received this message because you are subscribed to the Google Groups "Thinking Sphinx" group.
> To view this discussion on the web visit https://groups.google.com/d/msg/thinking-sphinx/-/F7qxQxuZ31wJ.
Sorry, I'm not yet sure what the cause of this problem is. If you're performing a search, there should be the SphinxQL statement in your development log - most certainly when accessing via a browser, but I would expect it even via Rails' console. That should could some clues as to what's different with the SphinxQL queries you've been testing directly.
--
Pat
> To view this discussion on the web visit https://groups.google.com/d/msg/thinking-sphinx/-/U6pU2wwdBr4J.