How to join a model in solr with sunspot rails

I need to join another model (GeoNameAlternateName) and try it according to the document. But for some reason, I get the following error:

ArgumentError: Unknown field option :prefix provided for field :name

My GeoNameCityModel is searchable as follows:

searchable do
text :name
string :feature_class
string :feature_code
latlon(:lonlat) { Sunspot::Util::Coordinates.new(lat, lon) }
join(:name, :prefix => "alternate", :target => GeoNameAlternateName, :type => :text, :join => { :from => :geonames_id, :to => :geonames_id })
end

Do both models have a field column? Could this intervene?

I work on mac osx, rails 4.1.8, ruby-2.1.1 / gems / sunspot _solr-2.1.1 / Solr Solr-specifications 4.2.0.2013.03.06.22.32.13.13 Solr-implementation 4.2.0 1453694 - rmuir - 2013-03-06 22:32:13 Lucene specs 4.2.0 Lucene implementation 4.2.0 1453694 - rmuir - 2013-03-06 22:25:29

+4
source share
2 answers

. , git repo

  gem 'sunspot_rails'  , :git => 'https://github.com/sunspot/sunspot.git'
  gem 'sunspot_solr', :git => 'https://github.com/sunspot/sunspot.git' # optional pre-packaged Solr distribution for use in development

:

join(:alternate_name,  :target => GeoNameAlternateName, :type => :text, :join => { :from => :geonames_id, :to => :geonames_id })

GeoNameAlternateName

 searchable do
    integer :geonames_id
    text :alternate_name
  end
0

"" sunspot 2.1.1, . , master

- :

Sunspot.setup(GeoNameAlternateName) do
 integer :id
 ... all other fields 
end

Sunspot.setup(GeoNameCityModel) do
 integer :id
 integer :geoname_id
 join(:name, :type => :text, :join_string => 'from=geoname_id to=id')
 ... all other fields 
end
+1

Source: https://habr.com/ru/post/1568031/


All Articles