Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
indexing to non-dynamic, pre-defined fields
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  7 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Jason Ronallo  
View profile  
 More options Nov 10 2010, 2:17 pm
From: Jason Ronallo <jrona...@gmail.com>
Date: Wed, 10 Nov 2010 14:17:53 -0500
Local: Wed, Nov 10 2010 2:17 pm
Subject: indexing to non-dynamic, pre-defined fields
Hi,
I'm using Sunspot to index Rails resources to Solr. Within my
searchable block is there a way to index to non-dynamic, pre-defined
fields? Is there any other way than setting lots of copyfields in my
Solr schema.xml?

I won't necessarily be using Sunspot for searching this index. I just
like having a simple DSL for indexing that also hooks into the
ActiveRecord lifecycle nicely so I don't have to concern myself with
those pieces.

Jason


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Mat Brown  
View profile  
 More options Nov 10 2010, 2:36 pm
From: Mat Brown <m...@patch.com>
Date: Wed, 10 Nov 2010 14:36:08 -0500
Local: Wed, Nov 10 2010 2:36 pm
Subject: Re: [sunspot] indexing to non-dynamic, pre-defined fields

In Sunspot 1.2 you can use the :as option to explicitly specify the field
name in Solr that you'd like to use.
On Nov 10, 2010 2:18 PM, "Jason Ronallo" <jrona...@gmail.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jason Ronallo  
View profile  
 More options Nov 10 2010, 3:41 pm
From: Jason Ronallo <jrona...@gmail.com>
Date: Wed, 10 Nov 2010 15:41:15 -0500
Local: Wed, Nov 10 2010 3:41 pm
Subject: Re: [sunspot] indexing to non-dynamic, pre-defined fields
Upgrading to sunspot_rails 1.2 pre some of this worked.

I have solr fields title_display and subject_facet I'm trying to index to.

searchable do
  string :title_display, :as => :title_display do |resource|
    resource.title
  end
  string :subject_facet, :as => :subject_facet do |r|
    r.subjects.map{|s| s.subject}
  end
end

This works in the case of a non-multiValued field in the case of
title_display. It fails for subject_facet with the error
"subject_facet is not a multiple-value field, so it cannot index
values". Including the option :multiple => true results in a different
error:
Solr Response: ERRORunknown_field_subject_facetm

Do I have my syntax wrong? If not it seems that in the case where the
:as option is specified it ought to either:
1. Not require the :multiple option to index an array. Someone using
the :as option will have to know their own Solr schema enough to know
whether the field is multiValued or not. So either a single value or
an Array ought to be accepted.
2. Require the :multiple option for indexing arrays, but not append
the "m" to the end of the field name. If :as is specified, then
Sunspot should never change that name based on any options.

Other options for this behavior? Or maybe I'm misunderstanding the
purpose of the :as option?

BTW, I've been unable to find a key for what all the Sunspot dynamic
field name suffixes mean. Where would I look for this?

Jason


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Mat Brown  
View profile  
 More options Nov 10 2010, 6:17 pm
From: Mat Brown <m...@patch.com>
Date: Wed, 10 Nov 2010 18:17:27 -0500
Local: Wed, Nov 10 2010 6:17 pm
Subject: Re: [sunspot] indexing to non-dynamic, pre-defined fields

Good catch -- #2 should be the behavior ; it's a bug that it isn't.

Built in schema.xml is as good a guide as any.
On Nov 10, 2010 2:41 PM, "Jason Ronallo" <jrona...@gmail.com> wrote:

ruby-sunspot+unsubscribe@googlegroups.com<ruby-sunspot%2Bunsubscribe@google groups.com>
.
> For more options, visit this group at

http://groups.google.com/group/ruby-sunspot?hl=en.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jason Ronallo  
View profile  
 More options Nov 10 2010, 7:14 pm
From: Jason Ronallo <jrona...@gmail.com>
Date: Wed, 10 Nov 2010 19:14:02 -0500
Local: Wed, Nov 10 2010 7:14 pm
Subject: Re: [sunspot] indexing to non-dynamic, pre-defined fields
Mat,
I've added a ticket for this and created a branch on my fork of
sunspot with a potential fix. An example was added to the post mock
and spec added to attributes_spec.rb.

Ticket:
http://outoftime.lighthouseapp.com/projects/20339-sunspot/tickets/149...

Branch:
https://github.com/jronallo/sunspot/tree/as_and_multiple

Commit diff:
https://github.com/jronallo/sunspot/commit/f2521f33723d6ace00a7ee92f9...

Please let me know if there's anything else I can do to help fix this bug.

Jason


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Mat Brown  
View profile  
 More options Nov 10 2010, 7:23 pm
From: Mat Brown <m...@patch.com>
Date: Wed, 10 Nov 2010 19:23:34 -0500
Local: Wed, Nov 10 2010 7:23 pm
Subject: Re: [sunspot] indexing to non-dynamic, pre-defined fields
That patch works, but I'd actually rather just store a single
@indexed_name variable, calculated at initialization time, which is
always the fully correct value. Then the #indexed_name method just
becomes an attr_reader . Does that make sense?


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jason Ronallo  
View profile  
 More options Nov 10 2010, 10:03 pm
From: Jason Ronallo <jrona...@gmail.com>
Date: Wed, 10 Nov 2010 22:03:31 -0500
Local: Wed, Nov 10 2010 10:03 pm
Subject: Re: [sunspot] indexing to non-dynamic, pre-defined fields
Thanks for reviewing the previous patch. I think I get what you're
getting at, but maybe you can tell me if I'm on the right track with
this:
https://github.com/jronallo/sunspot/tree/as_and_typed_indexed_name

Commits:
https://github.com/jronallo/sunspot/commit/00c0d0692ef6f1ded831499cb2...
https://github.com/jronallo/sunspot/commit/f393947ac75e8d7c8020f7bc69...

This eliminates the duplication in creating the indexed_name suffixes
that was happening between AttributeField and FulltextField. The
suffixes tested for between those classes varied slightly so maybe
there's a test missing for that difference. Maybe a FulltextField
should never have the multiple suffix even though multiple is always
true? I didn't see an explicit test for that.

This probably only works now because of the order in which the
AttributeField and FulltextField initializers assign to @multiple is
different. Also, since it is currently impossible to explicitly set
the option :multiple for a FulltextField because of the options.empty?
check.

I was still not able to get rid of FulltextField#indexed_name without
failing a lot of tests seemingly because of some interaction there
with boosting. FulltextField#indexed_name has been simplified to only
include a call to super, though.

Hopefully this is more on the right track.

Jason


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »