我正在尝试使用Elasticsearch中的一些索引文件使用ReactiveSearch和ReactiveMaps构建和应用。
Elasticsearch中的索引文件有一个字段“location”,例如:
"location": {
"Lat": 56.746423,
"Lon": 37.189268
}
以及“标题”或“作者”等其他领域。
我有一个Google maps API密钥,在我的App.js文件中,我有以下组件:
<DataSearch
componentId="mainSearch"
dataField={["Title", "Title.search", "Abstract", "Abstract.search"]}
queryFormat="and"
placeholder="Search for HEP"
autosuggest={true}
className="datasearch"
innerClass={{
input: "searchbox",
list: "suggestionlist"
}}
/>
<ReactiveMap
componentId="map"
dataField="location"
size={100}
defaultZoom={13}
defaultCenter={{ lat: 37.74, lng: -122.45 }}
showMapStyles={true}
defaultMapStyle="Standard"
showMarkerClusters={true}
showSearchAsMove={true}
searchAsMove={true}
react={{
and: "mainSearch"
}}
onData={result => ({
label: result.Title
})}
/>
在同一个文件(“App.js”)我有这样的行:
<ReactiveBase
app="title"
url=here_the_elasticsearch_cluster
mapKey="here_my_googlemapsAPI_key"
>
另外在我的文件Public / index.html中
<script
type="text/javascript"
src="https://maps.google.com/maps/api/js?v=3.34&key=MY_GOOGLE_MAPS_API_KEY&libraries=places"
></script>
但是,当我在mainBar中搜索任何文档时,我发现它,但是,当我点击它时,它不会出现在地图中。
我究竟做错了什么?
最后我解决了它。 ReactiveMaps不允许使用大写的位置字段,因此我必须更改elasticsearch中的索引文档。
"location": {
"lat": 56.746423,
"lon": 37.189268
}