Add custom field

411 views
Skip to first unread message

Jbiolaz

unread,
Oct 27, 2011, 10:42:22 AM10/27/11
to Sunspot
Hi,

I'm pretty new to Solr and Sunspot. I'm trying to index text in three
different text field, but I want that each one has a different
Analyzer set in the Schema.xml of Solr.

I already add my new field in the schema.xml and it's well recognized
by Solr:

<fieldType name="my_new_text_field" class="solr.TextField"
omitNorms="false"/>
And I define in it an analyzer.

I'm trying to add this to Sunspot. I want to have something like :

searchable do
text :some_text
my_new_text_field :some_text
end

What is the easy way to add a new field in Solr ?

Thanks for help !

Matthew A. Brown

unread,
Oct 27, 2011, 11:48:35 AM10/27/11
to ruby-s...@googlegroups.com
Hi,

What you've got below is a fieldType definition, which is the first
step. Then you need to add a dynamic field definition -- look in the
default schema for examples. Once you've got that in place, let's
assume you've defined your dynamic field with the suffix "*_mytext".
All you need to do is tell Sunspot to override its default internal
naming schema and use your field name instead:

searchable do
text :some_text, :as => :some_field_mytext
end

Sunspot will use "some_field_mytext" as the internal field name, which
Solr will match with your "*_mytext" dynamic field definition.

Mat

> --
> You received this message because you are subscribed to the Google Groups "Sunspot" group.
> To post to this group, send email to ruby-s...@googlegroups.com.
> To unsubscribe from this group, send email to ruby-sunspot...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/ruby-sunspot?hl=en.
>
>

Jbiolaz

unread,
Oct 28, 2011, 10:31:40 AM10/28/11
to Sunspot
Thanks for your fast answer !
It works well !

Cheers
Reply all
Reply to author
Forward
0 new messages