Just add something like this to your query string:
"user_id:10"
I typically use a drop-down on the view to let the user choose limiting
values like this, then I concatenate the field values in the query string
before calling find_by_contents or whatever.
You can find out a lot more about other query related options in the Lucene
documentation too:
http://lucene.apache.org/java/docs/queryparsersyntax.html
Thanks,
Doug
On 5/24/07, Giuseppe Bertini <giuseppe.bertini at gmail.com>
wrote:>
> Hello,
> I am exploring acts_as_ferret, and the first question that pops to mind
> is scoping, i.e. how to restrict searches in various ways.
>
> For example, I have a Post model with title, content, and user_id as
> attributes, and I want users to be able to search through their own
> posts only.
>
> Normally, of course, I would do
> Post.find(:all, :conditions=>["user_id=?", current_user],
> :joins=>"somejoins")
>
> What about ferret-ized models?
> Is there a clean way to impose such restrictions to the ferret search
> itself, or should one search the entire model first, and then use the
> returned ids to run a regular query with a "in" clause?
>
> Apologies if the answer to this is trivial, I cannot seem to google the
> relevant info.
>
> Cheers,
> Giuseppe
>
> --
> Posted via http://www.ruby-forum.com/.
> _______________________________________________
> Ferret-talk mailing list
> Ferret-talk at rubyforge.org
> http://rubyforge.org/mailman/listinfo/ferret-talk
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
http://rubyforge.org/pipermail/ferret-talk/attachments/20070524/18939f80/attachment.html