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

Add multilevel structure example #8

Open
pilot opened this issue Dec 4, 2015 · 9 comments
Open

Add multilevel structure example #8

pilot opened this issue Dec 4, 2015 · 9 comments

Comments

@pilot
Copy link
Contributor

pilot commented Dec 4, 2015

simple and ofter to use categories structure like:

  • category
    • sub category
  • category
  • category
    • sub category
    • sub category
@cigolpl
Copy link
Member

cigolpl commented Dec 4, 2015

Do you mean object structure for showing in the table:
selection_376

Or mapping example with object fields ?

@pilot
Copy link
Contributor Author

pilot commented Dec 4, 2015

image

this is usual case

@cigolpl
Copy link
Member

cigolpl commented Dec 4, 2015

Thanks for example. I don't think it will work with the current API version but it is definitely good use case for some requirements (i.e. ecommerce !?)

I am thinking about the implementation and wondering how to store data that elasticsearch will be aware that sub1 and sub2 are 'children' of category ?

parent field -
https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping-parent-field.html ?

@pilot
Copy link
Contributor Author

pilot commented Dec 4, 2015

not only for ecommerce, but for any catalog contain system, like a sales aggregation page

there is example of mapping for nested field from real project

variants:
                            type: "nested"
                            properties:
                                id:
                                    type: "integer"
                                status:
                                    type: "boolean"
                                prices:
                                    type: "nested"
                                    properties:
                                        value:
                                            type: "integer"
                                        oldValue:
                                            type: "integer"
                                        currencyCode:
                                            type: "string"
                                options:
                                    type: "nested"
                                    properties:
                                        id:
                                            type: "integer"
                                        value:
                                            type: "string"
                                            index: not_analyzed
                                        minSize:
                                            type: "integer"
                                        maxSize:
                                            type: "integer"

@cigolpl
Copy link
Member

cigolpl commented Dec 4, 2015

It is not easy for implementation but it would be great feature.
It seems there is a solution http://stackoverflow.com/a/26314598/659682 ;)

@pilot
Copy link
Contributor Author

pilot commented Dec 4, 2015

yeah this is looks like 👍

@cigolpl
Copy link
Member

cigolpl commented Dec 12, 2015

@pilot as I said this is great feature and even I would use it but it will take more time because I don't know yet how to make it simple and don't affect too much current functionality (import / export, / schema / response / elasticsearch mapping converting).

How would you like to provide data to ItemsAPI to achieve multilevel structure in API response ?

My idea is to add new aggregations type which override current terms aggregation and it will take additional field from item i.e. paths

var paths = [
  'category1': ['sub-category1', 'sub-category2'],
  'category2': ['sub-category1', 'sub-category3'],
  'category3': ['sub-category2', 'sub-category3'],
  'sub-category2': ['sub-sub-category1']
]

Current terms aggregation looks like:

{
  "aggregations": {
    "actors_terms": {"type": "terms", "field": "actors", "size": 10, "title": "Actors"},
  }
}

and the another new one aggregation could look like:

{
  "aggregations": {
    "actors_terms": {"type": "recursive_terms", "field": "category", "size": 10, "title": "Categories", "paths": "paths"},
  }
}

It would generate multilevel filters out of the box like in your picture.

Do you think does it make sense ?

@cigolpl
Copy link
Member

cigolpl commented Dec 12, 2015

I am sorry, configuration could look like this without additional field:

{
  "aggregations": {
    "actors_terms": {"type": "recursive_terms", "field": "category", "size": 10, "title": "Categories", "paths": [
      'category1': ['sub-category1', 'sub-category2'],
      'category2': ['sub-category1', 'sub-category3'],
      'category3': ['sub-category2', 'sub-category3'],
      'sub-category2': ['sub-sub-category1']
    ]},
  }
}

@pilot
Copy link
Contributor Author

pilot commented Dec 12, 2015

yes, to clarify above aggregations will valid only for nested type mapping?

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

No branches or pull requests

2 participants