Pat,

Thanks for the response, but I can't seem to get the code working.

My index block looks like this:

  define_index do
    indexes part_number
    indexes "REPLACE(REPLACE(part_number, '/', ''), '-', '')", :as
=> :part_number_alphanumeric
    indexes description, keywords
    indexes manufacturer.name, :as => :manufacturer_name
    indexes categories(:name), :as => :category_names
    has categories(:id), :as => :category_ids
    set_property :field_weights => {"part_number" => 100,
"description" => 50, "keywords" => 10}
    set_property :enable_star => true
    set_property :min_prefix_len => 3
    where "searchable = 1"
  end

And I get this error when I try to rake ts:config:

rake aborted!
Cannot define a field with no columns. Maybe you are trying to index a
field with a reserved name (id, name). You can fix this error by using
a symbol rather than a bare name (:id instead of id).


On Feb 24, 12:46 am, Pat Allan <[email protected]> wrote:
> Hi Josh
>
> There's a few approaches I can think of. First up is ignore_chars,  
> which could be used to strip out slashes and 
> dashes.http://sphinxsearch.com/docs/current.html#conf-ignore-chars
>
> However, a better approach might be to have three fields, all built  
> off the same column (assuming MySQL, change as needed):
>
>    indexes part_number
>    indexes "REPLACE(part_number, '/', '')", :as => :part_number_no_slash
>    indexes "REPLACE(REPLACE(part_number, '/', ''), '-', '')", :as  
> => :part_number_alphanumeric
>
> It's not the neatest looking approach, but it would keep your query  
> super-simple... well, provided you're not looking at focusing the  
> search on a specific field. If that's the case, I'd probably wrap all  
> three of the above options into a single field via raw SQL.
>
> Hope this helps.
>
> Cheers
>
> --
> Pat
>
> On 24/02/2009, at 4:38 PM, Josh Owens wrote:
>
>
>
> > Hey,
>
> > I am trying to use Thinking Sphinx to match cisco part numbers, but I
> > need to match a couple variations of the part number.
>
> > For example: I have a part number: WS-C19/28EEUG.  I need to match the
> > exact part number, but also WSC1928EEUG, and WSC-1928EEUG.  Is there a
> > way to strip out non-alphanumeric characters for matching, or would I
> > need to do it by hand in the search query and with an extra db field
> > that gets indexed?
>
> > Thanks for the help.
--~--~---------~--~----~------------~-------~--~----~
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