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

Nested search backend #9

Open
barseghyanartur opened this issue Aug 25, 2019 · 12 comments
Open

Nested search backend #9

barseghyanartur opened this issue Aug 25, 2019 · 12 comments
Labels
enhancement New feature or request help appreciated Help appreciated in progress Work in progress
Milestone

Comments

@barseghyanartur
Copy link
Owner

barseghyanartur commented Aug 25, 2019

WIP in branch nested-search-backends.

@barseghyanartur barseghyanartur added this to the 0.2 milestone Aug 25, 2019
@barseghyanartur barseghyanartur added enhancement New feature or request help appreciated Help appreciated labels Aug 25, 2019
@barseghyanartur barseghyanartur modified the milestones: 0.2, 0.4, 0.5 Sep 3, 2019
@barseghyanartur barseghyanartur modified the milestones: 0.5, 0.6 Sep 22, 2019
@barseghyanartur barseghyanartur added the in progress Work in progress label Oct 1, 2019
@seandavi
Copy link

seandavi commented Oct 9, 2019

I have some nested objects in my models that I'd like to search on. I see the in progress label added recently. Do you have a sketch of what you are thinking here?

The rough by-hand approach that I had been working toward was to implement graphene types for nested objects, including search, etc. I hadn't gotten to the point of resolving the queries, though.

@barseghyanartur
Copy link
Owner Author

@seandavi:

Sure, I have a sketch. This whole project is designed after django-elasticsearch-dsl-drf. See the link for getting an impression what could you expect from NestedFilteringFilterBackend, as well as from additional (yet to come) functionality of the current SearchFilterBackend. And all of that still to be applied to Graphene.

Thus, still a little bit vague and unclear as I'm not yet certain on the implementation details or feature release dates.

@seandavi
Copy link

seandavi commented Oct 9, 2019

Thanks, @barseghyanartur. That helps quite a bit to know the functionality you are aiming to achieve. I'll try to digest that a bit.

@barseghyanartur barseghyanartur modified the milestones: 0.6, 0.7 Oct 10, 2019
@barseghyanartur barseghyanartur modified the milestones: 0.7, 0.8, 0.10 Jul 21, 2020
@lingfromSh
Copy link
Contributor

Hi, @barseghyanartur . I am trying to work on this feature. But i'm not certain how a nested search query should display in GraphQL.

Have you got any idea about this?

allPostDocuments(
    search: {
        tag: 'Python'            # a simple field
        comments: {            # a nested field
            query: 'Python',   # query on configured fields
            # tag: 'Python'     # search on a single field
        }
    }
){
    tag
    category
    comments{
        author
        tag
    }
}

or

allPostDocuments(
    search: {
        tag: 'Python'            # a simple field
    }
    nestedSearch: {
        comments: {            # a nested field
            query: 'Python',   # query on configured fields
            # tag: 'Python'
        }
    }
){
    tag
    category
    comments{
        author
        tag
    }
}

@barseghyanartur
Copy link
Owner Author

@lingfromSh:

The first approach looks cleaner, although might be a little bit more difficult to implement, but I think we should aim for that (the first option). However, if it does not work out (or hard to implement in a generic way), we should fall back to the second option (which would be easy-peasy).

@barseghyanartur
Copy link
Owner Author

barseghyanartur commented Mar 8, 2021

P. S. I've merged your another PR into the master, but there are some issues with tests due to merging. I'm solving it later on today. I think tomorrow we'll have master all clean and working so that you could branch from that.

@lingfromSh
Copy link
Contributor

okay.

@barseghyanartur
Copy link
Owner Author

Master is updated. Changes released as 0.7.

@lingfromSh
Copy link
Contributor

Thanks for reminding.

And I see the current config format of search_fields like below.
search/common.py

search_fields = {
    'title': {'boost': 4, 'field': 'title.raw'},
    'content': {'boost': 2},
    'category': None,
}

It's inconvenient to set (when i have many fields but only one field need boost). Can i change them into this type?

# Type 3
search_fields = [
    {
        'field': 'title', 
    	'boost': 2
    },
    'content',
    'category',
    'description',
    'summary'
]

Although we may need a extra filter to find related option instead of search_fields.get(field) when in prepare_search_fields, i feel it worths.

Suggestions are welcomed.

@barseghyanartur
Copy link
Owner Author

@lingfromSh:

Let's leave the current config format intact. It's just the way it is.

@lingfromSh
Copy link
Contributor

Okay

@barseghyanartur barseghyanartur modified the milestones: 0.10, 0.8 Mar 16, 2021
@MamtaPrasad
Copy link

MamtaPrasad commented Jan 16, 2023

What is the sample query for Nested Search ? I am using version 0.8 of this library and have configured search_nested_fields .But when I query the nested data is coming as null. Please advise.
My schema is as below :
class address(InnerDoc):
city= Text(fields={"raw": Keyword()})
zip= Text(fields={"raw": Keyword()})

class person(Document):
name=Text(fields={"raw": Keyword()})
title=Text(fields={"raw": Keyword()})
address=Nested(address)

query is "
query { person(search:{name:{ value:"John" } }) { edges {node {name title address{city}}}}} "

getting this error : search_phase_execution_exception', 'failed to create query: [nested] failed to find nested object under path [address]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help appreciated Help appreciated in progress Work in progress
Projects
None yet
Development

No branches or pull requests

4 participants