How can I implement a sunspot search when it is nested

How to extend my search? I would like the user to user user_controllers # index when the user clicks the search button.

Now I have 3 models.

User> User_File> Prefecture

User_profile contains columns such as user_id and prefect_id.

In the prefecture, the model has its own identifier and name (Exp: California, New York)

Now I have installation models /user.rb like this. If I want to add a prefecture search, what should I add to this? The user must be able to enter California , and he performs a search.

searchable do text :user_profile_nickname do user_profile.nickname end text :user_profile_introduction do user_profile.introduction end text :tag_list do tag_list end end 
+4
source share
1 answer

Each user will be saved as a document in Solr, and you need to provide pre-task information to the user document so that it can be searchable.

Try:

 searchable do text :user_profile_nickname do user_profile.nickname end text :user_profile_introduction do user_profile.introduction end text :tag_list do tag_list end string :prefacture do user_profile.prefacture.name end end 

I would use a string instead of text, since you do not need to apply text processing, for example, with pre-processing. And with Sunspot, I don’t think it’s possible to build edges in text boxes.

+1
source

All Articles