@Christian: thanks again for the reply.
I tried the suggested version before and it does not seem to work:
1. ThinkingSphinx.facets does not show a "path" facet but a
"path_facet" facet in the result hash (also see script/console sample
below). Why the "path_facet" name?
2. The hash for this facet is always empty
My playground example is: Wine has_one GeographicFeature,
GeographicFeture is a tree (with the world as root and the deeper the
tree, the more specific the origin of the wine : world -> europe ->
italy -> tuscany)
So i created a query which returns
wines.id,
geographic_features.id
pairs like this:
+-----------+-----------+
| id | id |
+-----------+-----------+
| 51711515 | 140325849 |
| 51711515 | 566630862 |
| 51711515 | 574838058 |
| 51711515 | 930672604 |
| 887636893 | 27016372 |
| 887636893 | 140325849 |
| 887636893 | 574838058 |
| 887636893 | 930672604 |
+-----------+-----------+
(there are two wines, both from world -> europe -> italy but one is
from tuscany region while the other is from piedmont region)
and mapped it with
has SQL, :as => 'path', :source => :query, :facet => true
in wine.rb
rake ts:stop && rake ts:in && rake ts:start
script/console
Wine.facets
Querying Sphinx:
Wine Load (0.3ms) SELECT * FROM `wines` WHERE (`wines`.`id` IN
(887636893,51711515))
Querying Sphinx:
Querying Sphinx:
=> {:feature_name_facet=>{}, :path_facet=>{}, :name=>{"chianti"=>1,
"Asti Spumante"=>1}}
As you can see the path_name facet is empty.
I guess i'm doing a "facet noob" thing but can't see whats wrong. Any
idea?
As a second question: Why is there a SELECT * FROM wines? Why does
sphinx load the models when queried for facets?
Greetings from switzerland
Pascal
On Aug 19, 2:44 pm, Christian Aust <
datenimpera...@googlemail.com>
wrote:
> Just a quick thought;
>
> has 'REPLACE(geographic_feature.dotted_ids, '.',
> ',')', :as=>'path', :type=>:multi, :facet=>true
>
> or something along that line should make the attribute :path usable
> for a facet query, since Sphinx sees multiple integers separated by
> comma. Regards,
>
> Christian
>
> On 19 Aug., 14:26, pascal <
pascal.b...@gmail.com> wrote:
>
>
>
> > Christian thanks for your explanations.
>
> > I am playing around with the "acts as tree with dotted ids" from
> > xavier (
http://github.com/xavier/acts-as-tree-with-dotted-ids/tree/
> > master) which basically stores the "path" from a tree node in dotted
> > form, i.e. "3.12.34.65" indicates that the parent of node with ID 65
> > is the node with ID 34 and so on.
>
> > I indexed this dotted id as an attribute:
>
> > has geographic_feature.dotted_ids, :as => 'path', :type => :multi
>
> > and this works for filtering (though i'm not sure it should work;
> > since i thought sphinx only supports integers for attributes?). This
> > is nice since i do not need an aditional query or queries (as would be
> > required with acts as tree or nested set).
>
> > But unfortuanetly it does not work for facets. The facet hash for this
> > attribute is always empty.
>
> > The sentence
> > "....in the second one the field will be parsed for integer values..."
> > fromhttp://
www.sphinxsearch.com/docs/current.html#mvamademe think