Comments (8)
A custom doc id on the index Tank side?
Could you explain your question a little bit more?
from tanker.
Currently the docid is being assigned by tanker as follows:
Line 311 @ https://github.com/kidpollo/tanker/blob/master/lib/tanker.rb
create a unique index based on the model name and unique id
def it_doc_id
self.class.name + ' ' + self.id.to_s
end
I would like the docID to be comment.post.id so that every time there is a new comment the IndexTank record for that post gets updated with a string of all the posts comments. Currently every comment gets it's own IndexTank docid 'Comment 12' etc which I want to avoid.
Thoughts?
from tanker.
Hey @bhellman1
The reason tanker does doc ids that way is because we want to be able to use the same index for many of the models. The abstraction does the least it can do to correctly filter and intance new model objects. A contributor actually added the it_doc_id method because he wanted something similar though I never really understood why :P At the end the really did not need to change anything
What is the reason for avoiding Comment 12 may I ask?
from tanker.
I have the following models:
Post
Comment
I would like the search results to show Posts with a snippet & not a long list of Comments with duplicate post_ids in the results. The implementation idea being that in the Comment model I would add:
tankit 'rails_3_demo' do
indexes :comment_title
indexes :comment_collection
end
def comment_title
return self.post.title
end
def comment_collection
a = ''
self.post.comments.each do |comment|
a += comment.body
end
return a
end
And in IndexTank each post would be a document with a comment collection that is updated on every comment versus what's happening now which is every comment is a unique record in IndexTank.
Thoughts?
from tanker.
Does comment belong to post? If so why are you indexing all of the comments of the parent post all the time?
Why dont you just index on the Post model and the comments that go with it? You could have an instance method in Post called comment_collection not a comment_collection method in the comment model
Often times the simplest path is the best. Actually for the use case that you are telling me I would index comments individually and concentrate more on the query conditions to get the data as you want it. May be I am not understanding correctly
from tanker.
Thanks Kidpollo. Yes, comment does belong to post.
If I had the index in the post model with comment_collection. When a new comment was added how would I reindex the post index to include that comment? Thanks
from tanker.
Did this resolve the issue?
I am going to go ahead and close this
from tanker.
yep, thanks for asking!
from tanker.
Related Issues (20)
- How to sort results? HOT 1
- DEPRECATION WARNING: Yajl's JSON gem compatibility API is going to be removed in 2.0 HOT 1
- Can tanker drop records that can't be found? HOT 4
- can't search for words with special chars HOT 2
- Configuration HOT 1
- Facets
- cannot connect to index tank on other port besides 80
- AutoComplete
- rake tanker:functions is not finding defined fnctions HOT 1
- Feature request: access to `query_relevance_score` HOT 1
- Tanker::Utilities.clear_all_indexes throws an exception
- Search through several models HOT 1
- Model.tanker_reindex exception: Invalid document size. It shouldn't be bigger than 100KB. Got 103720 bytes HOT 1
- undefined method `conditions' (Rails 3.2.12, Tanker 1.1.6) HOT 3
- search_tank alters the options hash
- IndexTank::HttpCodeException: Incorrect api call HOT 1
- "indexable?" does not work HOT 1
- Facets?
- Model.tanker_reindex does not clear current index. Just updates?
- How do i define multiple values for category, and then search for it? HOT 1
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 tanker.