Definitely sounds like a good start. Might want to look at shellwords, which is
a good way of splitting up query terms and maintaining any quotes specified by
the user:
http://ruby-doc.org/core/classes/Shellwords.html
Also, you can use the :star => true option, which would simplify your query to:
Product.search "#{original_word} | #{stemmed_word}",
:match_mode => :extended,
:star => true
Cheers
--
Pat
On 16/12/2009, at 5:26 AM, Jon Crawford wrote:
> I'm trying out this stemmer gem for pre-stemming the word before
> passing it to Sphinx. http://github.com/aurelian/ruby-stemmer
>
> My strategy is to do Product.search("*#{original_word}* | *#
> {stemmed_word}*", :match_mode => :extended). Sound sane?
>
> Thanks again for your help!
>
> !jon
>
> On Dec 14, 9:04 pm, Pat Allan <[email protected]> wrote:
>> Unfortunately, I don't think there's any way to do this in Sphinx (though if
>> you'd like to double-check, I'd recommend posting to the Sphinx
>> forum).http://sphinxsearch.com/forum/
>>
>> An alternative could be to parse the query string into separate words, and
>> use ActiveSupport's singularize method. Of course, this isn't
>> super-reliable, but might be worth a shot.
>>
>> --
>> Pat
>>
>> On 15/12/2009, at 12:15 PM, Jon Crawford wrote:
>>
>>
>>
>>> Oh, wow. Yeah I had it backwards. My desired behavior would be for
>>> Product.search("dogs") to return a match for "dog". My users aren't
>>> too bright sometimes and they add an S to the end of a word and it
>>> rules out search results.
>>
>>> Example: Product.search("*shirts*) would rule out any product just
>>> tagged with "shirt".
>>
>>> Any suggestions for how to alter the actual search term to achieve
>>> this?
>>
>>> !jon
>>
>>> On Dec 14, 4:55 pm, Pat Allan <[email protected]> wrote:
>>>> Hi Jon
>>
>>>> Just to clarify -morphologyworks the opposite way around. You index dogs,
>>>> and search for dog, and it will get returned. If you index dog, and search
>>>> for dogs, you won't get the document returned. Was this your understanding
>>>> too?
>>
>>>> Also, I've just tested in my app, searching for '*dog*' matches SkyDog,
>>>> but '*dogs*' does not.
>>
>>>> I'm using the 0.9.9 release - not sure if it's worth upgrading (though
>>>> I've not heard ofmorphologybeing buggy before)... I can't spot anything
>>>> out of place in your index definition.
>>
>>>> --
>>>> Pat
>>
>>>> On 15/12/2009, at 5:26 AM, Jon Crawford wrote:
>>
>>>>> Thanks for the help, Pat.
>>
>>>>> I've got Sphinx 0.9.8.1-release (r1533). Still seeing this behavior
>>>>> after a couple days in production and many reconfig/rebuilds.
>>
>>>>> Ismorphologynot compatible with searching with star? Product.search
>>>>> ("*dogs*") should match "SkyDog" in a perfect world but does not.
>>
>>>>> Here's my define_index block:
>>
>>>>> define_index do
>>>>> indexes :name, :sortable => true
>>>>> indexes description
>>>>> indexes tags.name, :as => :tag_names
>>
>>>>> has created_at, store_id, deleted_at, cents, category_id
>>>>> has :active, :type => :boolean
>>>>> has store.active, :as => :store_active, :type => :boolean
>>>>> has store.admin_disabled, :as => :store_admin_disabled, :type
>>>>> => :boolean
>>>>> has taggings.tag_id, :as => :tag_ids
>>
>>>>> where "products.deleted_at IS NULL"
>>>>> end
>>
>>>>> On Dec 12, 1:59 am, Pat Allan <[email protected]> wrote:
>>>>>> Hi Jon
>>
>>>>>> I've just created some test data in a local app, and it seems to be
>>>>>> working fine for me (indeed, with the examples you've offered - an
>>>>>> object with running returns in a search for run, ditto for dogs/dog).
>>>>>> I've got the same settings in my sphinx.yml file...
>>
>>>>>> So, maybe it's something to do with the index setup? Can you provide a
>>>>>> bit more detail on what your define_index block looks like, and what
>>>>>> Sphinx version you're using?
>>
>>>>>> Cheers
>>
>>>>>> --
>>>>>> Pat
>>
>>>>>> On 12/12/2009, at 1:13 AM, Jon Crawford wrote:
>>
>>>>>>> And for a point of clarification, I checked the generated conf file
>>>>>>> and themorphologyis specified there.
>>
>>>>>>> index product_core
>>>>>>> {
>>>>>>> source = product_core_0
>>>>>>> path = /path/to/index/product_core
>>>>>>> morphology= stem_en
>>>>>>> charset_type = utf-8
>>>>>>> min_infix_len = 3
>>>>>>> enable_star = 1
>>>>>>> html_strip = 1
>>>>>>> }
>>
>>>>>>> On Dec 11, 12:42 am, Jon Crawford <[email protected]> wrote:
>>>>>>>> Using this configuration, I've tried it in development and staging.
>>>>>>>> But it's not changing the query according to the query log.
>>
>>>>>>>> development:
>>>>>>>> morphology: stem_en
>>>>>>>> enable_star: true
>>>>>>>> min_infix_len: 3
>>>>>>>> html_strip: true
>>
>>>>>>>> Product.search("dogs") should query for "dog", right?
>>>>>>>> Product.search("running") should query for "run", right?
>>
>>>>>>>> I've configured, indexed, restarted multiple times. Any suggestions?
>>
>>>>>>> --
>>
>>>>>>> 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
>>>>>>> athttp://groups.google.com/group/thinking-sphinx?hl=en.
>>
>>>>> --
>>
>>>>> 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
>>>>> athttp://groups.google.com/group/thinking-sphinx?hl=en.
>>
>>> --
>>
>>> 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
>>> athttp://groups.google.com/group/thinking-sphinx?hl=en.
>
> --
>
> 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.
>
>
--
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.