elasticsuite
elasticsuite copied to clipboard
GraphQL resolver to match results from sitewide search
I was wondering if there are any plans to add functionality in the form of a GraphQL query + resolver that would match the functionality produced by the modifications to the "/search/ajax/suggest" route (Products, Categories, Terms, etc)? While ElasticSuite does update the 'products' query, it doesn't provide a query to replace the existing non-GraphQL route (just products).
My team is working with a merchant currently who would like to use ElasticSuite as a companion to Elasticsearch but we have a requirement that the requests be made using GraphQL.
We've started working on a query + resolver of our own but are open to switching to an officially supported version if it's available or would be available in a reasonable timeframe.
What our query essentially does is mimic the "q" parameter given to "/search/ajax/suggest" route, injects that in place of the param (via interceptors) and then calls the \Magento\Model\Search\Autocomplete
model to get the results. We've been somewhat successful in that we're able to pull Products, Categories and Terms (though with some bugs that we're trying to squash :sweat_smile: )
We haven't been able to find any pull requests or issues that are after the same functionality so figured it best to ask! :smile:
Hi @romainruaud I've done it. I would love to show it to you if your satified with my approach. It still has some flaws in regards to Elastic Suite extensions like CMS. Are you interested?
hi @nige-one sure, don't hesitate submitting this, I think this could be definitely great
Hi @romainruaud please find my module at https://github.com/nige-one/module-elasticsuite-search-graph-ql/tree/master/src/module-elasticsuite-search-graphl-ql
I think a good starting point would be https://github.com/nige-one/module-elasticsuite-search-graph-ql/blob/master/src/module-elasticsuite-search-graphl-ql/etc/schema.graphqls
I've also already written another module to extend this module (by adding gql schema and registering classes) based on the CMS extension for Elastisuite. This could be done for every new SearchResultItem
type.
Please let me know if you would support my approach. After that I will contribute.