# On Ultrasphinx Associations

**URL:** <https://www.ruby-forum.com/t/on-ultrasphinx-associations/161370>\
**Category:** Rails\
**Created:** [February 25, 2009, 11:04pm UTC](https://www.ruby-forum.com/t/on-ultrasphinx-associations/161370 "2009-02-25T23:04:50Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![SergioMB](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/ebca7d/32.png) [@SergioMB](https://www.ruby-forum.com/u/SergioMB)\
**Post date:** [February 25, 2009, 11:04pm UTC](https://www.ruby-forum.com/t/on-ultrasphinx-associations/161370/1 "2009-02-25T23:04:50Z")

</div>

I am new to ultrasphinx and I am struggling with this issue.

I ve got a model with the following associations and is\_indexed  
options:

class Item  
has\_many :keywords

is\_indexed :fields =\> [‘id’, ‘collection\_id’,‘subject\_area’,  
‘special\_interest’, ‘notes’, ‘abstract’],  
:concatenate =\> [{:association\_name =\> ‘keywords’, :field =\>  
‘keyword’, :as =\> ‘keyword\_text’}]  
end

When I try this in the console:

> > @b=Ultrasphinx::Search.new(:query =\> “Immoral behavior”).run.results

I get 5 objects back, they do so because I know they match one of the  
keywords in the :keywords assocations

[#\<Item id: 329, collection\_id: 117, notes: “”, size\_scope: “25  
items”, special\_interest: “”, subject\_area: “WIH”, abstract: “While  
Evaline (Eva) Foster was in Malaysia from 189…”\>,  
#\<Item id: 308, collection\_id: 137, notes: “This letter originated  
from: Crittenden Family Pape…”, size\_scope: “16 pages”,  
special\_interest: “”, subject\_area: “WIH”, abstract: “While his wife,  
Clara Jones Crittenden, stayed with…”\>, #\<Item id: 1214,  
collection\_id: 110, notes: “”, size\_scope: “35 letters  
(approximately)”, special\_interest: “”, subject\_area: “A-A”, abstract:  
“Of the Fenno-Hoffman Family papers, the letters wri…”\>,  
#\<Item id: 271, collection\_id: 319, notes: “M-3462.2”, size\_scope: “1  
page”, special\_interest: “”, subject\_area: “WIH”, abstract: “Joseph F.  
Huntoon wrote this letter to his wife, Be…”\>,  
#\<Item id: 1207, collection\_id: 2, notes: “”, size\_scope: “3 pages”,  
special\_interest: “”, subject\_area: “A-A”, abstract: “Letter from  
Oliver Swaine Taylor to an unidentified…”\>]

The problem is that in the fields retrieved in each object I don’t see  
the one I specified in the : concatenate options named ‘keyword\_text’  
which is the one causing the matching.

Any help on how I can have access to those fields?

thanks!  
s.
