magento / catalog-storefront

Open Software License 3.0
7 stars 18 forks source link

[EAP] Search Service in Storefront App #374

Open mslabko opened 4 years ago

mslabko commented 4 years ago

As a Headless Magento Commerce Customer, 

I would like to search the entire catalog for products or limit the search on selected filters

So that

I can get to the products  I want in a fast and efficient manner. 

Acceptance Criteria

 

Implementation details

For the 1st Phase as a "transition" solution was decided to go with the following approach:

Search Service may be a simple wrapper on \Magento\Framework\Api\Search\SearchInterface::search to simplify implementation

 

 

 

m2-assistant[bot] commented 4 years ago

Hi @mslabko. Thank you for your report. To help us process this issue please make sure that you provided sufficient information.

Please, add a comment to assign the issue: @magento I am working on this


mslabko commented 4 years ago

New GQL schema which should be supported

type Price {
    amount: Float,
    currency: String
}

type ProductItem {
    id: ID
    sku: String
    url: String
    imageUrl: String
    price: Price
    name: String
}

# If from or to fields are omitted, $gte or $lte filter will be applied
input SearchRangeInput {
    from: Float
    to: Float
}

input SearchClauseInput {
    attribute: String!
    # an array of values to filter on
    in: [String]
    # a string to filter on
    eq: String
    # range to filter on
    range: SearchRangeInput
}

# This enumeration indicates whether to return results in ascending or descending order
enum SortEnum {
    ASC
    DESC
}

input ProductSearchSortInput {
    attribute: String!
    direction: SortEnum!
}

type SearchResultPageInfo {
    # Specifies which page of results to return
    currentPage: Int
    # Specifies the maximum number of items to return
    pageSize: Int
    # Total pages
    totalPages: Int
}

interface Bucket {
    #Human readable bucket title
    title: String!
}

type StatsBucket implements Bucket {
    title: String!
    min: Float!
    max: Float!
}

type ScalarBucket implements Bucket {
    title: String!
    #Could be used for filtering and may contain non-human readable data
    id: ID!
    count: Int!
}

type RangeBucket implements Bucket {
    title: String!
    from: Float!
    to: Float!
    count: Int!
}

type Aggregation {
    title: String!
    attribute: String!
    buckets: [Bucket]!
}

type Highlight {
    attribute: String!
    value: String!
    matchedWords: [String]!
}

type ProductSearchItem {
    product: ProductItem!
    highlights: [Highlight]
}

type ProductSearchResponse {
    totalCount: Int
    items: [ProductSearchItem]
    facets: [Aggregation]
    suggestions: [String]  # Should be ignored, available only for "Live Search"
    relatedTerms: [String] # Should be ignored, available only for "Live Search"
    pageInfo: SearchResultPageInfo
}

type Query {
    productSearch(phrase: String!,
                    pageSize: Int = 20,
                    currentPage: Int = 1,
                    filter: [SearchClauseInput!],
                    # One or more sortings are applied to the same results.
                    sort: [ProductSearchSortInput!]): ProductSearchResponse!

    notImplemented(searchRangeInput: SearchRangeInput):Bucket
    scalarBucket: ScalarBucket
    statsBucket: StatsBucket
    rangeBucket: RangeBucket
}

# Only a single graphql file (in the project) should have schema definition.
# other graphql files must not have schema definition.
schema {
    query: Query
}
lykhachov commented 4 years ago

@magento I am working on this

m2-assistant[bot] commented 4 years ago

Hi @lykhachov! :wave: Thank you for collaboration. Only members of Community Contributors Team are allowed to be assigned to the issue. Please use @magento add to contributors team command to join Contributors team.

lykhachov commented 4 years ago

https://github.com/magento/magento2/pull/30778