Tire::Index#store supports the "parent" option #256

Closed
wants to merge 1 commit into
from

Projects

None yet

3 participants

@nickhoffman

Hi there, Karel. This pull request enables users to store documents in a parent-child relationship.

Tire::Index#store can be told to set the parent option in the query string. Eg:

Product.tire.index.store doc, :parent => doc.parent.id
@nickhoffman nickhoffman Tire::Index#store supports the "parent" option
This enables users to store documents in a parent-child relationship.
978d632
@karmi
Owner
karmi commented Mar 1, 2012

Hi Nick, as with #258, this is all hacking what should be done more systematically, exposing all the useful parameters for Search API. In the end, all of this is just a simple hash of options, encoded as URL params.

I'm reluctant to proceed with that in a piecemeal fashion...

@nickhoffman

I hear you! It'd be great to support all of these options in one nice refactoring, rather than, as you said, adding support for options one by one.

Do you have any ideas on how to support all of the options for the ES' Search API?

@karmi
Owner
karmi commented Mar 1, 2012

Yes, all the options are scattered around, see eg. model/search.rb which is crazy and hell from maintenance standpoint.

For search, I think we should somehow work with possible options directly in lib/tire/search.rb! I must to have a look into that...

Maybe we can just serialize options send to Index#store and pass them to ES? Once I'm done with all the pull requests and stuff, I'll try to have a look into that as well... But feel free to submit a pull request for that, Nick!

@nickhoffman

Serializing the options to Tire::Index#store might be the fastest and simplest approach. If I submit a pull request for that, it'd be merged in?

@mattiassvedhem
Contributor

Is there a work around for doing this ?

@mattiassvedhem
Contributor

Hi @karmi any update on this? What could be done to move in this direction?

@karmi
Owner
karmi commented Jun 28, 2012

@yeggeps Making sure Index#store works with the passed in options, calling to_param on them as eg. https://github.com/karmi/tire/blob/master/lib/tire/search.rb#L119, not breaking anything (= not sending bogus options down to ES), proper unit tests for the feature and ideally an integration test demonstrating the purpose (not the bare functionality) of the feature...

@mattiassvedhem
Contributor

@karmi cool, has any work been done on this? if not I might take a stab at it.

@karmi
Owner
karmi commented Jun 28, 2012

@yeggeps Not yet. I would definitely try to solve all the options related issues across the whole codebase as soon as possible.

@karmi karmi added a commit that referenced this pull request Oct 23, 2012
@karmi [REFACTOR] Cleaned up the `Index#store` method
* Restructure the code
* Use `params` Hash to encode URL parameters for elasticsearch
* Prepare solving #256 in a more robust way
01828d3
@karmi karmi added a commit that referenced this pull request Oct 23, 2012
@karmi [#256] Added support for the `parent` URL parameter in `Index#store`
This patch builds upon work in nickhoffman/tire@978d632 by @nickhoffman,
and the refactoring in karmi/retire@01828d3.

It allows to pass a `parent` parameter to Index#store.

See "Parents & Children" in <http://www.elasticsearch.org/guide/reference/api/index_.html>

Note, that adding support for other URL parameters, such as routing, timestamp, TTL, etc.
is just a matter of adding proper key in the `params` hash and adding tests.

Closes #256.
12a0fed
@karmi karmi added a commit that closed this pull request Oct 23, 2012
@karmi [#256] Added support for the `parent` URL parameter in `Index#store`
This patch builds upon work in nickhoffman/tire@978d632 by @nickhoffman,
and the refactoring in karmi/retire@01828d3.

It allows to pass a `parent` parameter to Index#store.

See "Parents & Children" in <http://www.elasticsearch.org/guide/reference/api/index_.html>

Note, that adding support for other URL parameters, such as routing, timestamp, TTL, etc.
is just a matter of adding proper key in the `params` hash and adding tests.

Closes #256.
12a0fed
@karmi karmi closed this in 12a0fed Oct 23, 2012
@karmi
Owner
karmi commented Oct 23, 2012

@nickhoffman Nick, sorry about taking so long to process this... In the end, I've cleaned up the params handling in Index#store opening it up for support for other URL parameters, such as routing, ttl, etc.

@mattiassvedhem
Contributor

Awesome @karmi! Any idea when it will make it to the gem? Thanks.

@karmi
Owner
karmi commented Oct 23, 2012

@mattiassvedhem No idea :), please use the Git URL in the Gemfile for the time being...

@nickhoffman

Great work, @karmi. Thanks for not forgetting about this feature.

@NOX73 NOX73 added a commit to NOX73/tire that referenced this pull request Oct 23, 2012
@karmi @NOX73 + NOX73 [REFACTOR] Cleaned up the `Index#store` method
* Restructure the code
* Use `params` Hash to encode URL parameters for elasticsearch
* Prepare solving #256 in a more robust way
ab71951
@NOX73 NOX73 added a commit to NOX73/tire that referenced this pull request Oct 23, 2012
@karmi @NOX73 + NOX73 [#256] Added support for the `parent` URL parameter in `Index#store`
This patch builds upon work in nickhoffman/tire@978d632 by @nickhoffman,
and the refactoring in karmi/retire@01828d3.

It allows to pass a `parent` parameter to Index#store.

See "Parents & Children" in <http://www.elasticsearch.org/guide/reference/api/index_.html>

Note, that adding support for other URL parameters, such as routing, timestamp, TTL, etc.
is just a matter of adding proper key in the `params` hash and adding tests.

Closes #256.
17121f5
@NOX73 NOX73 added a commit to NOX73/tire that referenced this pull request Oct 23, 2012
@NOX73 NOX73 Merge branch 'master' into works-br
* master: (36 commits)
  Added test for facet_filter
  Added support for boosting query
  [#472] Added support for loading partial fields
  [#269] Added the `min_score` DSL method
  [#269] Added the `min_score` DSL method
  [TEST] Refactored equality checks in expectations fot the `Index` unit tests
  [#256] Added support for the `parent` URL parameter in `Index#store`
  [REFACTOR] Cleaned up the `Index#store` method
  [#446] Changed, that arbitrary objects passed in the `:as` mapping option are indexed
  Improved support for Kaminari pagination
  Added proper `Results::Collection#slice` implementation
  Added Rake task to generate ENV['COUNT'] records into the template for the Rails example application
  Added `attr_accessible` to Article model in the template for example Rails application
  [FIX] Simplified `method_missing` in `Item`
  [FIX] Implemented `respond_to?` for `Item`
  [FIX] Added, that a warning is displayed when the index cannot be created on class load
  Changed, that "edge" version of Tire is used in the Rails application template
  Exit with an error in the Rake import task when the index as not created in elasticsearch
  Added the ability to pass arguments to the `all` query
  [FIX] [#453] Changed Hash syntax to be Ruby 1.8 compatible in Tire::Model::Persistence::Finders
  ...
fdd8caf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment