Here’s an example to illustrate what I’m trying to do:
Suppose I have a one-to-many relationship between a Cookbook and Recipe, with fields ‘id’ and ‘name’ in both tables. Currently, searches return only a “name” field for recipes, so results might look like this –
RECIPES
- result name 1
- result name 2
- result name 3
- …
What I’d like to see, without making additional database calls or search queries using the sql_attr_uint for the foreignkey, is the following:
RECIPES
- result name 1 ———- cookbook name for this result
- result name 2 ———- cookbook name for this result
- result name 3 ———- cookbook name for this result
- …
I know of sql_attr_string, but this appears useful only when adding a single arbitrary string to each document. I need something like a sql_joined_field that isn’t full-text searchable, but is instead simply stored in the document with the appropriate value from the query.
Any suggestions are appreciated.
I believe I stumbled upon the solution, having been a bit confused by the Sphinx documentation:
I took this to mean that no matter what, fields I placed in the sql_query would be full-text indexed. In fact, specifying a field as an “attribute” changes this behavior, in effect removing the full-text indexing of the field and instead just placing it in the document.
To solve my problem, I simply wrote my JOIN in the main sql_query (since sql_joined_field doesn’t appear to allow one to specify it as an attribute) and set the field as sql_attr_string.