Ah, I'm aware of this issue... the problem is Sphinx's str2ordinal  
(read: string) attributes are only calculated on a per-index basis.  
Which means delta index and core index ordering are calculated  
separately.

I've been thinking on how to get around this, and Sphinx does allow  
updates to attributes - but only integer, boolean and datetime  
attributes. Not str2ordinal, not floats. Otherwise, we could run a  
task in the background that recalculated ordering across the two  
indexes instead of just scanning one. Even then, it's a bit hackish.

I'll put a post on the Sphinx forums, see if we can get str2ordinal  
updating into 0.9.9 before the proper release.

Cheers

-- 
Pat

On 12/02/2009, at 9:02 PM, David Faber wrote:

>
> Hey Guys,
>
> I'm having a somewhat similar problem with searches involving the
> (default approach to the) delta index.  While the text-search actually
> seems to be doing what it should, ordering by attributes on records in
> the delta index is behaving a bit unpredictably.
>
> Here's an example of the problem, I tried to make it as concise but
> thorough as possible, hopefully its still clear though.
>
> I've defined an index in a model called Brand like this:
> define_index do
>  indexes name, :sortable => true
>  set_property :delta => true
> end
>
> Then I added a couple records, and did a full index with rake ts:in,
> so the delta is empty and the core is up to date.  Here's the output
> of a script that reproduced the problem:
>
> ==> @brand1: #<Brand id: 1, name: "Microsoft", delta: false,
> created_at: "2009-02-12 09:53:08", updated_at: "2009-02-12 09:53:08">
> ==> @brand2: #<Brand id: 2, name: "Apple", delta: false, created_at:
> "2009-02-12 09:53:08", updated_at: "2009-02-12 09:53:08">
> ==> Execute: "Brand.search(:order => 'name asc')"
> ==> Result: [#<Brand id: 2, name: "Apple", delta: false, created_at:
> "2009-02-12 09:53:08", updated_at: "2009-02-12 09:53:08">, #<Brand id:
> 1, name: "Microsoft", delta: false, created_at: "2009-02-12 09:53:08",
> updated_at: "2009-02-12 09:53:08">]
> ==> Change @brand1 name to "Xerox"
> Sphinx 0.9.8-release (r1371)
> Copyright (c) 2001-2008, Andrew Aksyonoff
>
> using config file '/Users/faber/tmp/broken_sphinx/rails/config/
> development.sphinx.conf'...
> indexing index 'brand_delta'...
> collected 1 docs, 0.0 MB
> collected 0 attr values
> sorted 0.0 Mvalues, 100.0% done
> sorted 0.0 Mhits, 100.0% done
> total 1 docs, 5 bytes
> total 0.014 sec, 348.82 bytes/sec, 69.76 docs/sec
> rotating indices: succesfully sent SIGHUP to searchd (pid=33881).
> ==> Wait for 10 seconds
> ==> Execute: "Brand.search(:order => 'name asc')"
> ==> Result: [#<Brand id: 1, name: "Xerox", delta: true, created_at:
> "2009-02-12 09:53:08", updated_at: "2009-02-12 09:53:12">, #<Brand id:
> 2, name: "Apple", delta: false, created_at: "2009-02-12 09:53:08",
> updated_at: "2009-02-12 09:53:08">]
> ==> Execute: "Brand.search('xerox')"
> ==> Result: [#<Brand id: 1, name: "Xerox", delta: true, created_at:
> "2009-02-12 09:53:08", updated_at: "2009-02-12 09:53:12">]
> ==> Execute: "Brand.create(:name => 'Aardvark')"
> Sphinx 0.9.8-release (r1371)
> Copyright (c) 2001-2008, Andrew Aksyonoff
>
> using config file '/Users/faber/tmp/broken_sphinx/rails/config/
> development.sphinx.conf'...
> indexing index 'brand_delta'...
> collected 2 docs, 0.0 MB
> collected 0 attr values
> sorted 0.0 Mvalues, 100.0% done
> sorted 0.0 Mhits, 100.0% done
> total 2 docs, 13 bytes
> total 0.016 sec, 792.39 bytes/sec, 121.91 docs/sec
> rotating indices: succesfully sent SIGHUP to searchd (pid=33881).
> ==> Result: #<Brand id: 3, name: "Aardvark", delta: true, created_at:
> "2009-02-12 09:53:22", updated_at: "2009-02-12 09:53:22">
> ==> Wait for 10 seconds
> ==> Execute: "Brand.search(:order => 'name asc')"
> ==> Result: [#<Brand id: 2, name: "Apple", delta: false, created_at:
> "2009-02-12 09:53:08", updated_at: "2009-02-12 09:53:08">, #<Brand id:
> 3, name: "Aardvark", delta: true, created_at: "2009-02-12 09:53:22",
> updated_at: "2009-02-12 09:53:22">, #<Brand id: 1, name: "Xerox",
> delta: true, created_at: "2009-02-12 09:53:08", updated_at:
> "2009-02-12 09:53:12">]
>
>
> (Apologies for the big ugly bunch of text) This shows that the sorting
> by name works initially, then doesn't seem to work with entries
> indexed in the delta.  If after this I ran rake ts:in again,
> everything would work again.
>
> Can you see where I'm going wrong?  I've never noticed this problem
> working with thinking-sphinx before, but I don't really have a huge
> amount of experience with it so maybe it's been happening all along.
> FYI, I'm running Sphinx 0.9.8 (r1371), Rails 2.2.2, Ruby 1.8.6, and
> ThinkingSphinx 1.1.5 on a Macbook Pro.
>
> Thanks so much, I appreciate all your work,
> David
>
> On Feb 11, 6:21 pm, Pat Allan <[email protected]> wrote:
>> Hmm, okay. What version of Rails are you using, and what's the output
>> of the following:
>>
>> e = Expense.new :amount=>1, :creator_id=>1, :business_id=>1
>> e.due_date = Date.today
>> e.save
>> e.send(:should_toggle_delta?)
>> Expense.index_delta(e)
>> client = Riddle::Client.new "localhost", 11002
>> client.query "", "expense_delta"
>>
>> Cheers
>>
>> --
>> Pat
>>
>> On 12/02/2009, at 12:20 AM, Steven Bristol wrote:
>>
>>
>>
>>> On Wed, Feb 11, 2009 at 12:04 AM, Pat Allan <p...@freelancing-
>>> gods.com> wrote:
>>
>>>> No worries... (although it wasn't so much a holiday - at least part
>>>> of
>>>> the time - more working-from-Cambodia).
>>
>>>> So, we're not seeing the output of the delta task (just to confirm:
>>>> you're using the default delta approach, yeah?)... to check whether
>>>> there's path issues, what's the output of the following in script/
>>>> console:
>>>> `indexer`
>>
>>>> If that complains about missing args, path is fine. If it complains
>>>> that it doesn't know about the executable indexer, then it's a path
>>>> problem.
>>
>>>> Cheers
>>
>>>> --
>>>> Pat
>>
>>> Yes, the default delta approach. (AFAIK, I'm only aware of one delta
>>> approach.) Here is my define:
>>>  define_index do
>>>    indexes amount, title, check_number, notes, business_id
>>>    indexes [client.name, client.company_name], :as=>:client_name
>>>    indexes [payee.name, payee.company_name], :as=>:payee_name
>>>    indexes [employee.name,  
>>> employee.company_name], :as=>:employee_name
>>>    indexes [contractor.name,
>>> contractor.company_name], :as=>:contractor_name
>>>    indexes expense_category.name, :as=>:expense_category_name
>>>    where "repeated_template = false"
>>>    set_property :delta => true
>>>    set_property :enable_star => true
>>>    set_property :morphology => 'none'
>>>  end
>>> It complained about missing args.
>
> >


--~--~---------~--~----~------------~-------~--~----~
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