I need to search over Model1, but the query should "look" also in Model2 if
there is a match aand if there is, it returns Model1 which has relation with
Model2 which contains searched string.

But i'll take look at Haystack, maybe it'll be better for my needs.

Thanks a lot.



David De La Harpe Golden-3 wrote:
> 
> On 13/04/10 09:04, urukay wrote:
>> Hi,
>>
>> I'm trying to create full text search on model, everything goes fine
>> when
>> searching TextFields but I have a problem with ForeignKey field.
>>
>> How can i do that? Can anyone point me to the right direction?
>>
> 
> Do you mean you want the results for Model2 searches to include Model2 
> instances when when a search string matches text in any of the Model1 
> instances related to the Model2 instance?
> 
> If you're don't actually need sphinx in particular but rather you are 
> looking for the ability to full-text search django models, then 
> http://haystacksearch.org/ makes adding search facilities to django 
> projects extremely easy. With haystack and the handily-pure-python 
> whoosh, you can be up and running basic searches of your django models 
> in a matter of minutes.  In the case of the foreign key field, with 
> haystack, you could just include texts from related Model1s in the 
> search template for Model2.  That's of course a tad wasteful in some 
> ways, but OTOH might be exactly what you want.
> 
> I don't use django-sphinx so I'm not clear how to do it there, but
> a conceptually related approach does work with raw sphinx apparently: 
> you can use joins in sql_query in your source declarations. see this:
> http://stackoverflow.com/questions/1733816/sphinx-and-one-to-many-associations
> 
> [Obviously, you could also search multiple times for a given search 
> string submission and then do joins on the various results yourself, 
> though that could get painful fast.]
> 
> Full text search isn't appropriate for everything, so django-filters is 
> also handy to remember for filter query-building type stuff.
> 
> http://github.com/alex/django-filter
> 
> -- 
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
> 
> 
> 

-- 
View this message in context: 
http://old.nabble.com/Django-Sphinx-Foreign-key-search-tp28228784p28633984.html
Sent from the django-users mailing list archive at Nabble.com.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to