-
Notifications
You must be signed in to change notification settings - Fork 15
Include Flex::Scopes in module throws "uninitialized constant ModelName::Flex::Scopes" #9
Comments
True! Thanks for pointing that out: I will fix the example in the doc. |
BTW: how do I chain a Flex scope (which is in a module) with an ActiveRecord scope/relation? Example:
|
Not sure to understand what you need. A Flex scope and a AR scope are 2 different things: the first is defining a search criteria in the index, the second in the DB. Index and DB have usually quite different structures and it's practically impossible to integrate them. If you need to search the index, then use For example, supposing you have a :user_id field in the projects: def flex_source
{ :name => name, :user_id => user_id }
end
module Flex
...
scope :search_by_user_id_and_name, ->(user_id, name) { terms(user_id: user_id, name: name) }
...
end Or you can write 2 scopes one for the user_id and another for the project name, then chain them together when you need both or use them separately at will. |
Yeah, I thought so, this was actually my first solution - I was just curious if maybe there is a way. I'm having a problem actually with a basic search, just by :name
Flex has the data
But when I do:
Nada, any ideas? |
If you enter the complete content of the field ("Public test") you should get it. Please, refer to the elasticsearch doc for the term query. |
Well, actually it doesn't work for complete fraze because the words need to be seperate (and downcase as well). I ended up with custom filters (to get prefixes and filter ids)
Thanks for the help! |
Example:
This throws
NameError: uninitialized constant Project::Flex::Scopes
on server start. I had to doThe text was updated successfully, but these errors were encountered: