1

我正在开发一个基于Searchkit的项目,我在其中提供了来自 elasticsearch 服务器的搜索、过滤和排序功能。这是渲染的反应代码的一部分:

<SearchkitProvider searchkit={searchkit}>
        <Layout>
        <TopBar>
            <SearchBox placeholder="Rechercher..." 
                    autofocus={true} 
                    searchOnChange={true} 
                    queryOptions={{analyzer:"standard"}}
                    prefixQueryFields={["juridiction", "decision", "annee", "content"]}/>
        </TopBar>

        <LayoutBody>

        <SideBar>
            <RangeFilter min={0} max={10000} field="indemnite" id="indemnite" title="Indemnité" showHistogram={false}/>
            <RefinementListFilter id="demandeur" title="Demandeur" field="demandeur.keyword" operator="OR" size={10}/>
            <RefinementListFilter id="defendeur" title="Defendeur" field="defendeur.keyword" operator="OR" size={10}/>
            <RefinementListFilter id="juridiction" title="Juridiction" field="juridiction.keyword" operator="OR" size={10}/>
            <RefinementListFilter id="decision" title="Decision" field="decision.keyword" operator="OR" size={10}/>
            <RefinementListFilter id="annee" title="Annee" field="annee.keyword" operator="OR" size={10}/>
        </SideBar>

                <LayoutResults>
                <Tabs>
                    <TabList>
                        <Tab>Décisions Sources</Tab>
                        <Tab>Synthèse</Tab>
                    </TabList>
                    <TabPanel>
                        <ActionBar>
                            <ActionBarRow>
                                <HitsStats translations={{
                                "hitstats.results_found":"{hitCount} résultats trouvés"
                                }}/>
                                <ViewSwitcherToggle/>
                                <SortingSelector options={[
                                {label:"Indemnité", field:"indemnite", order:"desc"},
                                {label:"Dernières Décisions", field:"dateDecision", order:"desc"}
                                ]}/>
                            </ActionBarRow>

                            <ActionBarRow>
                                <GroupedSelectedFilters/>
                                <ResetFilters/>
                            </ActionBarRow>
                        </ActionBar>
                        <Hits hitsPerPage={12} highlightFields={["juridiction", "decision", "annee"]}
                        sourceFilter={["juridiction", "decision", "annee", "content", "indemnite", "dateDecision", "lieu"]}
                        itemComponent={HitsListItem}
                        mod="sk-hits-list"
                        scrollTo="body"/>
                        <NoHits suggestionsField={"juridiction"}/>
                        <Pagination showNumbers={true}/>
                    </TabPanel>
                    <TabPanel>
                        <!-- Here I will place the charts -->
                    </TabPanel>
                </Tabs>
                </LayoutResults>
        </LayoutBody>
        </Layout>
    </SearchkitProvider>

现在我想创建一些图表来显示聚合操作的结果(例如:)SELECT SUM(...) FROM ... GROUP BY ...

我希望能够从 SearchkitProvider 组件中获取构建的查询。如果我成功了,我不确定是否可以使用 Searchkit 库在构建的查询之上添加聚合。如果没有,我真的需要一个解决方案。

4

0 回答 0