【问题标题】:MultiList/MultiDropdownList not showing or throwing errors in ReactMultiList/MultiDropdownList 未在 React 中显示或抛出错误
【发布时间】:2018-12-05 02:08:46
【问题描述】:

我一直在努力让一些多面搜索选项在 ReactiveSearch/ReactiveBase 中工作。

当尝试让 MultiList 或 MultiDropdownList 工作时,没有显示它应该在哪里工作,并且开发工具中也没有任何错误消息。

SingleRange 部分工作得非常好,但我无法让任何文本 MultiList 功能正常工作。

这是我的整个“渲染”部分,以防万一我遗漏了一些简单的东西:

render() {
    return (
        <ReactiveBase
            app="properties"
            url="http://<el-server-ip>:9200">
            <CategorySearch
                    componentId="searchbox"
                    dataField={["PropertyType","County"]}
                    categoryField="Country"
                    autoSuggest={true}
                    fuzziness={0}
                    queryFormat="and"
                    placeholder="Search for properties"
            />
            <SingleRange
                    componentId="ratingsfilter"
                    title="Filter by ratings"
                    dataField="Price_Unformatted"
                    data={[
                        {"start": 0, "end": 500000, "label": "0 - 500k"},
                        {"start": 500000, "end": 1000000, "label": "500k - 1m"},
                        {"start": 1000000, "end": 10000000, "label": "1m - 10m"},
                        {"start": 0, "end": 1000000000000, "label": "10m+"},
                    ]}
                />
            <MultiList
              componentId="TypeSensor"
              dataField="PropertyType.raw"
              title="Type"
            />
                <ResultCard
                    componentId="result"
                    title="Results"
                    dataField="PropertyType"
                    from={0}
                    size={15}
                    pagination={true}
                    react={{
                        and: ["searchbox", "ratingsfilter","TypeSensor"]
                    }}
                    onData={(res) => {
                        return {
                            image: res.PicNumber,
                            title: res.PropertyType,
                            description: res.Description_EN.substr(0,100)
                        }
                    }}
            />
        </ReactiveBase>
    );
}

为了让您了解我正在使用的数据类型,以防万一类型不匹配导致错误:

"_source": {
                "objectID": 211956,
                "Continent": "Europe",
                "Country": "France",
                "County": "Aude ",
                "Location": "Carcassonne",
                "Area": null,
                "Price": "EUR 890,000",
                "Price_Unformatted": 890000,
                "PropertyType": "Chateau",
                "Bedrooms": 9,
                "Bathrooms": 6,
                "PicNumber": "file.jpg",
                "Description_EN": "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat...",
                "Currency": "EUR",
            }

在这种情况下,有什么方法可以从 React 或 ReactiveSearch 获取某种输出/错误消息,以便我可以准确地看到问题所在?

我之前也看到过错误,但主要是语法错误。

【问题讨论】:

  • 您的映射看起来如何?
  • 好主意,我检查了所有映射,它们对应于我检查的一大块数据。 Aka,它应该可以正常工作。
  • 您好,我已经在这里上传了映射:jsonblob.com/52568041-7b79-11e8-a427-5be7ca0d11bc 我希望这没问题。
  • 谢谢,你能看看我的回答吗?我认为它现在应该可以工作了。

标签: reactjs elasticsearch reactivesearch


【解决方案1】:

MultiList 必须在提供的 dataField 上运行聚合。在mappings 中,您应该使用keyword 类型,以便可以在其上运行聚合。因此,如果您将多字段更新为.keyword 而不是.raw,它应该可以工作:

<MultiList
  componentId="TypeSensor"
  dataField="PropertyType.keyword"
  title="Type"
/>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-05-06
    • 1970-01-01
    • 2013-03-21
    • 1970-01-01
    相关资源
    最近更新 更多