Pat,

Also, it seems that passing the type :date does not work, while :datetime
does, however my underlying column (in mysql) is just a date column, so
there is some extra information being returned.

Do you know if it is possible to make it treat the date column as integers
or else just dates?  I think before I updated to the latest version passing
:date was resulting in integer (unixtime) dates being returned by the call
to facets.

-Matt

On Tue, Jan 27, 2009 at 9:39 PM, Matt Murphy <[email protected]> wrote:

> Pat,
>
> Just tested w/o explicitly setting the column types and got the following:
>
> NoMethodError: You have a nil object when you didn't expect it!
> The error occurred while evaluating nil.columns
>     from
> /path/to/project/vendor/plugins/thinking-sphinx/lib/thinking_sphinx/attribute.rb:230:in
> `type_from_database'
>     from
> /path/to/project/vendor/plugins/thinking-sphinx/lib/thinking_sphinx/attribute.rb:236:in
> `translated_type_from_database'
>     from
> /path/to/project/vendor/plugins/thinking-sphinx/lib/thinking_sphinx/attribute.rb:148:in
> `type'
>     from
> /path/to/project/vendor/plugins/thinking-sphinx/lib/thinking_sphinx/facet.rb:29:in
> `value'
>     from
> /path/to/project/vendor/plugins/thinking-sphinx/lib/thinking_sphinx/facet_collection.rb:17:in
> `add_from_results'
>     from
> /path/to/project/vendor/plugins/thinking-sphinx/lib/thinking_sphinx/collection.rb:118:in
> `each_with_groupby_and_count'
>     from
> /path/to/project/vendor/rails/activerecord/lib/active_record/attribute_methods.rb:211:in
> `each_with_index'
>     from
> /path/to/project/vendor/plugins/thinking-sphinx/lib/thinking_sphinx/collection.rb:117:in
> `each'
>
>
> -Matt
>
>
> On Mon, Jan 26, 2009 at 9:36 PM, Pat Allan <[email protected]>wrote:
>
>>
>> Ah, I think I've got it figured out. The clue was in an email from
>> Nicolas (slainer68), who was having the same problem. It turns out,
>> the attribute didn't know which model it belonged to, and that
>> information was only provided when indexing happens. Of course, in my
>> test suite, indexing happens at the start of every run, hence why I
>> was never having problems.
>>
>> I've now made sure model is set as part of the define_index block, so
>> you shouldn't need to explicitly set the type now (and if someone
>> could double-check, that would be fantastic).
>>
>> Cheers
>>
>> --
>> Pat
>>
>> On 25/01/2009, at 2:05 PM, Matt Murphy wrote:
>>
>> > Pat,
>> >
>> > I used :string, :integer, and :datetime.
>> >
>> > -Matt
>> >
>> > On Sat, Jan 24, 2009 at 7:33 PM, Pat Allan <p...@freelancing-
>> > gods.com> wrote:
>> >
>> > Each facet is an additional attribute in the underlying setup - so
>> > that'd mean indexing is a bit slower, but not noticeably. I think
>> > complex SQL queries is far worse at slowing down indexing, via lots of
>> > association joins.
>> >
>> > Also: what was the attribute type for your facet? I need to figure out
>> > why you've both had that issue but my tests are fine...
>> >
>> > Cheers
>> >
>> > --
>> > Pat
>> >
>> > On 25/01/2009, at 3:46 AM, Matt Murphy wrote:
>> >
>> > > Also I just realized that I'm wondering about any indexing overhead
>> > > imposed by adding facets... thoughts?
>> > >
>> > > On Sat, Jan 24, 2009 at 11:15 AM, Matt Murphy <[email protected]>
>> > > wrote:
>> > > Tom & Pat:
>> > >
>> > > Tom's suggestion worked!
>> > >
>> > > Thanks much guys,
>> > >
>> > > -Matt
>> > >
>> > >
>> > > On Sat, Jan 24, 2009 at 7:04 AM, Tom Hunter <[email protected]>
>> > > wrote:
>> > > Matt,
>> > >
>> > > I am using it successfully with sphinx 0.9.9.  I had the same error
>> > > at first.  Explicitly declaring the type on the field fixed it.  For
>> > > example:
>> > >
>> > > has 'category_id, :facet => true
>> > >
>> > > would cause the same error, but changing it to:
>> > >
>> > > has 'category_id, :facet => true, :type => :integer
>> > >
>> > > would fix it.
>> > >
>> > > This is using MySQL.
>> > >
>> > > - Tom
>> > >
>> > >
>> > > On Sat, Jan 24, 2009 at 2:55 AM, Pat Allan <p...@freelancing-
>> > > gods.com> wrote:
>> > >
>> > > Hi Matt
>> > >
>> > > What's your define_index block looking like? I'll double-check the
>> > > tests against 0.9.9.
>> > >
>> > > --
>> > > Pat
>> > >
>> > > On 24/01/2009, at 2:47 PM, Matt Murphy wrote:
>> > >
>> > > > Pat,
>> > > >
>> > > > Do you know if facets work in the sphinx-0.9.9 branch?  I'm
>> > getting
>> > > > an exception when I call Model.facets.  I've just added :facet =>
>> > > > true to a few of the columns in the index definition.  Are there
>> > any
>> > > > column types that can't be treated as a facet?
>> > > >
>> > > > Error below:
>> > > >
>> > > > >> Model.facets
>> > > > NoMethodError: You have a nil object when you didn't expect it!
>> > > > The error occurred while evaluating nil.columns
>> > > >     from /path/to/project/vendor/plugins/thinking-sphinx/lib/
>> > > > thinking_sphinx/attribute.rb:230:in `type_from_database'
>> > > >     from /path/to/project/vendor/plugins/thinking-sphinx/lib/
>> > > > thinking_sphinx/attribute.rb:236:in
>> > `translated_type_from_database'
>> > > >     from /path/to/project/vendor/plugins/thinking-sphinx/lib/
>> > > > thinking_sphinx/attribute.rb:148:in `type'
>> > > >     from /path/to/project/vendor/plugins/thinking-sphinx/lib/
>> > > > thinking_sphinx/facet.rb:29:in `value'
>> > > >     from /path/to/project/vendor/plugins/thinking-sphinx/lib/
>> > > > thinking_sphinx/facet_collection.rb:17:in `add_from_results'
>> > > >     from /path/to/project/vendor/plugins/thinking-sphinx/lib/
>> > > > thinking_sphinx/collection.rb:118:in `each_with_groupby_and_count'
>> > > >
>> > > >
>> > > >
>> > > >
>> > > > On Wed, Jan 21, 2009 at 6:50 PM, Pat Allan <p...@freelancing-
>> > > > gods.com> wrote:
>> > > >
>> > > > Hi Tom
>> > > >
>> > > > You need to define the facets in your define_index block -
>> > either by
>> > > > using existing fields or attributes:
>> > > >   indexes location, :facet => true
>> > > >   has age, :facet => true
>> > > > Or by adding an explicit column for the facet:
>> > > >   facet location
>> > > >
>> > > > Keep in mind facets need to have unique names across facets,
>> > > > attributes and fields - so you couldn't put all three of the above
>> > > > lines together, you'd need to give the last one an alias via
>> > the :as
>> > > > option.
>> > > >
>> > > > Once that's set up and you've stopped Sphinx, re-indexed and
>> > > > restarted, then you can use it on the model as follows:
>> > > >   Model.facets
>> > > > Which returns a collection accessible as a hash, with keys for
>> > each
>> > > > facet and results as the values. You can also drill down into a
>> > full
>> > > > result set:
>> > > >   Model.facets.for(:location => "Melbourne")
>> > > >
>> > > > There's also a little bit more detail in this gist:
>> > > > http://gist.github.com/48328
>> > > >
>> > > > Multi-model faceting is not supported *yet*, but it's in the
>> > > pipeline.
>> > > >
>> > > > Cheers
>> > > >
>> > > > --
>> > > > Pat
>> > > >
>> > > > On 22/01/2009, at 4:27 AM, Tom Hunter wrote:
>> > > >
>> > > > >
>> > > > > Could someone give me a brief explanation of how to use the
>> > > facets?
>> > > > > I'm not sure quite what to put as arguments when calling the
>> > > facets
>> > > > > method and if anything needs go to in the define_index block?
>> > > > Thanks
>> > > > > in advance!
>> > > > >
>> > > > > - Tom Hunter
>> > > > >
>> > > > > >
>> > > >
>> > > >
>> > > >
>> > > >
>> > > >
>> > > > >
>> > >
>> > >
>> > >
>> > >
>> > >
>> > >
>> > >
>> > >
>> > >
>> > > >
>> >
>> >
>> >
>> >
>> >
>> > >
>>
>>
>> >>
>>
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Thinking Sphinx" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/thinking-sphinx?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to