Skip to content

Remove scope support in query and facet dsl. #2606

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

Closed
martijnvg opened this issue Jan 31, 2013 · 1 comment
Closed

Remove scope support in query and facet dsl. #2606

martijnvg opened this issue Jan 31, 2013 · 1 comment

Comments

@martijnvg
Copy link
Member

Remove support for the scope field in facets and _scope field in the nested and parent/child queries. The scope support for nested queries will be replaced by the nested facet option and a facet filter with a nested filter. The nested filters will now support the a join option. Which controls whether to perform the block join. By default this enabled, but when disabled it returns the nested documents as hits instead of the joined root document.

Search request with the current scope support.

curl -s -XPOST 'localhost:9200/products/_search' -d '{
    "query" : {
        "nested" : {
            "path" : "offers",
            "query" : {
                "match" : {
                    "offers.color" : "blue"     
                }
            },
            "_scope" : "my_scope"
        }
    },
    "facets" : {
        "size" : {
            "terms" : {
                "field" : "offers.size"
            },
            "scope" : "my_scope"
        }
    }
}'

The following will be functional equivalent of using the scope support:

curl -s -XPOST 'localhost:9200/products/_search?search_type=count' -d '{
    "query" : {
        "nested" : {
            "path" : "offers",
            "query" : {
                "match" : {
                    "offers.color" : "blue"     
                }
            }
        }
    },
    "facets" : {
        "size" : {
            "terms" : {
                "field" : "offers.size"
            },
            "facet_filter" : {
                "nested" : {
                    "path" : "offers",
                    "query" : {
                        "match" : {
                            "offers.color" : "blue"     
                        }
                    },
                    "join" : false
                }   
            },
            "nested" : "offers"
        }
    }
}'

The scope support for parent/child queries will be replaced by running the child query as filter in a global facet.

Search request with the current scope support:

curl -s -XPOST 'localhost:9200/products/_search' -d '{
    "query" : {
        "has_child" : {
            "type" : "offer",
            "query" : {
                "match" : {
                    "color" : "blue"        
                }
            },
            "_scope" : "my_scope"
        }
    },
    "facets" : {
        "size" : {
            "terms" : {
                "field" : "size"
            },
            "scope" : "my_scope"
        }
    }
}'

The following is the functional equivalent of using the scope support with parent/child queries:

curl -s -XPOST 'localhost:9200/products/_search' -d '{
    "query" : {
        "has_child" : {
            "type" : "offer",
            "query" : {
                "match" : {
                    "color" : "blue"        
                }
            }
        }
    },
    "facets" : {
        "size" : {
            "terms" : {
                "field" : "size"
            },
            "global" : true,
            "facet_filter" : {
                "term" : {
                    "color" : "blue"    
                }
            }
        }
    }
}'
@btiernay
Copy link

join should be added to the documentation. I totally missed this functionality.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants