Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Searching question #72

Closed
charlie-ablett opened this issue Sep 22, 2014 · 4 comments
Closed

Searching question #72

charlie-ablett opened this issue Sep 22, 2014 · 4 comments

Comments

@charlie-ablett
Copy link

I have a model with a one-to-many association. It's indexed on [:start], ie
field :start, value: ->(thing) { thing.bars.map(&:start) }

Foo has_many Bars

Bar belongs_to Foo

Each bar has a field called start which is a DateTime. I want to get any foo objects with at least one bar that occurs in the future. So that should not include any foos with no bars or bars with only past dates.

Using the Chewy syntax, I'd like to query ElasticSearch to retrieve all foo objects with at least one bar where start > Time.zone.now.

I've tried a few ways but it's not obvious how to do that. (not sure if this an "issue" but a usage question!)

@charlie-ablett
Copy link
Author

I've tried

scope.filter(range: {start: {gte: Time.zone.now }} )

and

scope.filter(range: {start: {gte: Time.zone.now }} ).filter_mode('1')

with no joy. Seems to only return foos with any bars, even if they are in the past...

@pyromaniac
Copy link
Contributor

Show me index mapping definition

@charlie-ablett
Copy link
Author

edited above

@charlie-ablett
Copy link
Author

Ah, I was missing "type: date" from the index.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants