Comments (5)
There's no way to do this right now. The best way (in your simple example) would be to change search data to:
def search_data
as_json(only: [:title, :created_at]).merge(user_id: user.id)
end
The ability to query nested documents would be nice as long as it's simple. I'm going to remove the nested example from the readme for now.
from searchkick.
Right, I thought that the merging could do it, but I'd be doing it for a number of associated model properties. It might be okay, so I'll try that out. Handling associations would be a great addition later. Thanks.
from searchkick.
Ah, and I forgot the other issue, which is that I'm dealing with a set of associated objects, which gets trickier of course. For example, if I have Items and each Item has many Users, and I need to be able to search for all of the Items with name "Foo" that are associated with a specific user. It's not well-suited for the merge solution. Thanks again.
from searchkick.
While you can't search nested attributes, you can search arrays.
class Item
def search_data
{user_ids: users.pluck(:id)}
end
end
And
Item.search "Foo", where: {user_ids: 1}
Hopefully that helps with your last comment.
from searchkick.
Created a new issue for nested queries #145
from searchkick.
Related Issues (20)
- While using opensearch-ruby got error: end of file reached (Faraday::ConnectionFailed) HOT 1
- Default index name doesn't use UTC time HOT 1
- minor issue when when doing a full reindex in queue mode HOT 1
- Make "Searchkick.search" for multi-model searches work with Rails low-level caching HOT 4
- Why is `_script` filters commented out in the source code? Possible to add support for scripts? HOT 2
- Index different objects to different indices HOT 2
- Integrate partial reindexing with mode_async bulk reindexing
- `scope_results` outputs incorrect warnings HOT 1
- rails production env indexmissing issue HOT 1
- Ability to set body_options globally in the same way you can model_options
- Clarify use of ActiveRecord `where` in `search_import` HOT 1
- Unable to load dynamic synonyms with Elastic HOT 1
- Support for Dynamoid (DynamoDB) HOT 2
- Add Semantic Search support HOT 2
- Make it also possible to set track_total_hits to an integer HOT 1
- Share indexes across environments? HOT 1
- Add support search_pipeline for OpenSearch client HOT 1
- No Mapping Found Error HOT 1
- Request level options for update requests HOT 2
- Attempting a full reindex can intermittently return an 'index_not_found_exception' HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from searchkick.