Skip to content
This repository has been archived by the owner on Feb 20, 2019. It is now read-only.

Add has_child and has_parent support #226

Open
pziemkowski opened this issue Mar 28, 2014 · 8 comments
Open

Add has_child and has_parent support #226

pziemkowski opened this issue Mar 28, 2014 · 8 comments
Milestone

Comments

@pziemkowski
Copy link

I would like to use has_child query, which requires me to pass another query as a value.

Here is the process_query method.

class HasChildS(S):
            def process_query_has_child(self, key, val, action):
                return {'has_child', {'type': key, 'query': val}}

From what I understand, right now it is impossible to pass another query as a value, e.g.

HasChildS(SomeMappingType).query(type_name__has_child=Q(foo="bar"))
@willkg
Copy link
Member

willkg commented Apr 2, 2014

With the code you've written, you can't accept a Q argument. You need to process the Q turning it into Elasticsearch JSON stuff.

You probably want something like this:

    def process_query_has_child(self, key, val, action):
        return {'has_child', {'type': key, 'query': self._process_queries([val])}}

@jmizgajski
Copy link

Or we could do it using Q and F parametrized with child type, to keep the API clean, something like:

S().query(has_child=Q(child_field=search_text), child_type=some_type) 

which would give more flexibility

@willkg
Copy link
Member

willkg commented Apr 2, 2014

I don't think you can do that without rewriting how S._process_queries works.

Now that I'm re-reading what you've written, I don't think I understand what you're asking for in this issue. Are you asking for support on code you've written that isn't working? Or are you asking to have support for something new in ElasticUtils and tossing around how it could be implemented?

@willkg willkg added this to the 0.10 milestone May 20, 2014
@willkg
Copy link
Member

willkg commented May 30, 2014

@jmizgajski ^^^ ?

@jmizgajski
Copy link

I think your solution is sound, you can close it or add support to the new release the way you described it.

@willkg
Copy link
Member

willkg commented May 30, 2014

I'm going to bump this to post-0.10 where we'll have a lot more wiggle room for new features and refactoring.

@willkg willkg removed this from the 0.10 milestone May 30, 2014
@gregorth
Copy link

any news here?

@jmizgajski
Copy link

Parent child can be easily implemented by appropriate mapping definition
and raw queries.

2014-07-31 14:50 GMT+02:00 Grzegorz Ślusarek [email protected]:

any news here?


Reply to this email directly or view it on GitHub
#226 (comment)
.

@willkg willkg added this to the 0.11 milestone Aug 19, 2014
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants