elasticsearch-geo-shape 相关问题


单击 p 标签旁边的按钮时获取 p 标签的内部文本(无 Jquery)

我有几个盒子,每个盒子都包含按钮和一个 元素,其内部文本是由 API 中的数据创建的。我在每个框上放置了一个 onclick(包裹 的 ) 我有几个盒子,每个盒子都包含按钮和一个 <p> 元素,其内部文本是由 API 中的数据创建的。我在每个框上放置了一个 onclick(包裹 <div> 元素和按钮的 <p>)。我希望每次单击该按钮时,位于该按钮旁边(位于同一 div 中)的 innerText 标签的 <p> 都会控制台日志。目前无法弄清楚,这就是我到目前为止所得到的: const containerShapes = document.getElementById("container-pock-shape") fetch("https://pokeapi.co/api/v2/pokemon-shape") .then(res => res.json()) .then(data => data.results.map(item => { return containerShapes.innerHTML += `<div class="shape-box" onclick="showName(event)"> <p>${item.name}</p> <button>Select</button> </div>` })) function showName(e) { console.log() } #container-pock-shape { display: flex; flex-wrap: wrap; } .shape-box { border: 2px solid red; display: flex; flex-direction: column; align-items: center; padding: 10px; width: 200px; } .shape-box p { background-color: grey; width: 100px; text-align: center; font-weight: 900; } <body> <div id="container-pock-shape"> </div> </body> 您可以使用最近的。当您需要 forEach 或正确使用地图时也不要使用地图 我还强烈建议授权(点击 div) const containerShapes = document.getElementById("container-pock-shape") fetch("https://pokeapi.co/api/v2/pokemon-shape") .then(res => res.json()) .then(data => containerShapes.innerHTML = data.results .map(({name}) => `<div class="shape-box"> <p>${name}</p> <button>Select</button> </div>`)); containerShapes.addEventListener("click", e => { const tgt = e.target.closest("button") if (tgt) console.log(tgt.closest("div.shape-box").querySelector("p").innerText) }) #container-pock-shape { display: flex; flex-wrap: wrap; } .shape-box { border: 2px solid red; display: flex; flex-direction: column; align-items: center; padding: 10px; width: 200px; } .shape-box p { background-color: grey; width: 100px; text-align: center; font-weight: 900; } <body> <div id="container-pock-shape"></div> </body> 要获取名称,由于事件位于整个 div 上,因此您需要使用 querySelector 并找到内部 <p> 元素并获取其文本。 const containerShapes = document.getElementById("container-pock-shape") fetch("https://pokeapi.co/api/v2/pokemon-shape") .then(res => res.json()) .then(data => data.results.map(item => containerShapes.innerHTML += `<div class="shape-box" onclick="showName(this)"> <p>${item.name}</p> <button>Select</button> </div>` )) function showName(box) { const name = box.querySelector('p').textContent; console.log(name); } #container-pock-shape { display: flex; flex-wrap: wrap; } .shape-box { border: 2px solid red; display: flex; flex-direction: column; align-items: center; padding: 10px; width: 200px; } .shape-box p { background-color: grey; width: 100px; text-align: center; font-weight: 900; } <body> <div id="container-pock-shape"></div> </body> 执行此操作的另一种方法是将单击事件仅添加到按钮,然后查找 closest 形状框,然后找到 <p>。 const containerShapes = document.getElementById("container-pock-shape") fetch("https://pokeapi.co/api/v2/pokemon-shape") .then(res => res.json()) .then(data => data.results.map(item => containerShapes.innerHTML += `<div class="shape-box"> <p>${item.name}</p> <button onclick="showName(this)">Select</button> </div>` )) function showName(button) { const name = button.closest('.shape-box').querySelector('p').textContent; console.log(name); } #container-pock-shape { display: flex; flex-wrap: wrap; } .shape-box { border: 2px solid red; display: flex; flex-direction: column; align-items: center; padding: 10px; width: 200px; } .shape-box p { background-color: grey; width: 100px; text-align: center; font-weight: 900; } <body> <div id="container-pock-shape"></div> </body> 嘿,我最近找到了解决此问题的简单方法(当然,如果您的文本不像按钮文本那样太长):您可以将内部文本作为元素的 id 提供。并且在事件处理程序中,您可以通过以下方式访问内部文本:这样:e.target.id希望这个解决方案可以帮助你:)


Kibana 无法从 Elasticsearch 节点检索版本信息。 getaddrinfo EAI_AGAIN elasticsearch

我正在尝试通过 docker-compose.yml 文件安装 kibana 和 elasticsearch,我得到了 {"type":"log","@timestamp":"2024-01-09T18:24:14+00:00 “,”标签...


Elasticsearch:何时将 omit_norms 选项设置为 false

elasticsearch 中 omit_norms 选项的良好用例是什么?我在 es 网站上找不到足够的解释。


将文档写入磁盘时,ElasticSearch(lucene) 段是必须的吗?

我想知道将文档写入磁盘时是否需要 Lucene 段。 以下是文档如何从 ElasticSearch 写入磁盘的简要过程 首先,将ElasticSearch文档写入...


如何记录所有执行的elasticsearch查询

我想查看针对 Elasticsearch 实例执行的所有查询。是否可以在调试模式下运行elasticsearch,或者告诉它存储针对它执行的所有查询? 目的是...


Llama-index 如何针对 OpenSearch Elasticsearch 索引执行搜索查询?

我有以下代码,可以在 Opensearch Elasticsearch 中创建索引: def openes_initiate(文件): 端点 = getenv("OPENSEARCH_ENDPOINT", "http://localhost:9200&...


branch 不是使用 yup 模式与 when 和 then 进行反应的函数

在使用 yup 进行反应时,我创建了这个模式 const RefereeFormSchema = Yup.object().shape({ name: Yup.string().required('姓名为必填项'), 移动端:Yup.string().matches(APP_CONFIG.REGEX_PHO...


Golang elasticsearch TypedClient 聚合如何循环结果

我正在使用 Elastic 的官方 Elasticsearch Go Typed Client 包来查询 uniq 服务名称,为此我构建了一个聚合搜索。查询成功,响应包含Bu...


使用elasticsearch 6过滤文档中的对象数组,删除不匹配的对象

在elasticsearch 6.0中,我创建了一个具有嵌套映射类型的索引: 放置节点2 { “设置” : { “指数” : { “分片数量”:3, ...


Elasticsearch 密码重置失败并显示 https

当我尝试使用以下命令重置弹性搜索密码时(在弹性搜索的 bin 目录中)。 elasticsearch-重置密码-u弹性-i 它抛出以下错误。 警告:忽略 JAVA_...


ElasticSearch 正则表达式使用“ ”

我知道ElasticSearch不使用PRCE,并且它的操作有限,但我想知道是否有什么方法可以使用 在正则表达式中。 例如,弹性搜索不支持 \d 但我们可以使用 [0...


如何使用css制作如图所示的圆形波浪边框?

图像的右侧是问题所在,我无法将边框做成像这样的波浪。 我希望它弯曲但不对称。 这是我使用的最接近的(https://css-generators.com/wavy-shape...


我有一个elasticsearch索引,一个名为“authority”的字段,它有多个字符串值,我想要最后一个逗号后面的最后一个值?

elasticsearch 索引名称为 data1 @authority 字段有时包含多个值或单个值 “@权威”: [ “恒星”, “克里斯”, “利昂娜”, “我……


向 ElasticSearch 中的文档添加新字段

我在ES中有一个索引,其文档格式如下 "_id": "9hGu8IwBXomVfLb-UJJo", “_score”:1, “_来源”: { “主持人”: { &


Kibana_system 无法验证弹性用户

我遇到了一个不知道如何解决的问题。 我已在本地安装了elasticsearch和kibana版本8.7.1,并按照本指南创建了证书: https://quachtd.com/


Elastic APM 服务器在 Docker 中不可用

我正在尝试运行 apm-server 使用 apm-agent 从基于 java 的应用程序收集并发送给 Elasticsearch。 这是我的撰写文件: 服务: 订单服务: 图片:apm-java/order-service:1.0.0 ...


Elasticsearch:如何在curl 命令中使用Painless 脚本引用嵌套字段名称

我有一个轻松的脚本,可以在控制台中运行,但在curl中失败。该脚本引用嵌套字段 (event.orinal)。 在 Kibana 控制台中,此语句运行良好: ctx._source.event.remove('


Spring data elasticsearch repository.count() 返回“当前令牌 (VALUE_NUMBER_INT) 不是布尔类型”

我正在将一个相当旧的应用程序从 Spring Boot 2.0.2 升级到最新的应用程序。 中期目标是更新到最新版本 2 (2.7.18) 所以这可能是一个依赖版本...


恢复Elasticsearch快照时出错

我使用curl 从 1 个集群创建了一个快照。当我尝试在另一个集群上使用curl 恢复快照时,第二个集群无法分配所有索引。集群 1 有 2 个节点,集群 2 有 1 个节点。我...


为什么ElasticSearch将主分片和副本分片放在同一主机上?

这是添加到现有集群测试中的新主机,触发了重新平衡过程。 两个节点node-5、node-6位于新物理主机中。 对于每个分片,只有一个主分片...


为什么ElasticSearch将主分片和副本分片放在同一主机上?

这是添加到现有集群测试中的新主机,触发了重新平衡过程。 两个节点node-5、node-6位于新主机中。 对于每个分片,只有一个主分片和一个


RestHighLevelClient 在尝试向 ElasticSearch 发送请求时给出“无法识别的参数”

我正在尝试连接到我的应用程序中的一个本地 ES 系统。以前它是一个不同的集群。最近,我们的 ES 团队将其迁移到启用了基本身份验证的不同集群。我...


有没有办法确定日志的优先级并将其发送到elasticsearch,以优化服务器上的日志负载

需要读取我的环境中所有应用程序日志中的严重、错误和警告。如果在 1000 次警告后发生严重情况,我希望 Logstash 立即发送它,并给予较高的优先级......


android 高度隐藏布局的所有视图

我的布局如下面的屏幕截图所示。 我的代码如下。 我的布局如下面的屏幕截图所示。 我的代码如下。 <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@color/white" > <LinearLayout android:id="@+id/ll_main" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginStart="@dimen/margin_smallxx" android:layout_marginTop="@dimen/margin_normalxx" android:layout_marginEnd="@dimen/margin_smallxx" android:orientation="vertical"> ....... 现在我想为盒子添加阴影,如下所示。 <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@color/white" > <TextView style="@style/shadowStyle" android:elevation="20dp" android:layout_alignTop="@id/ll_main" android:layout_alignBottom="@id/ll_main" android:layout_alignStart="@id/ll_main" android:layout_alignEnd="@id/ll_main" /> <LinearLayout android:id="@+id/ll_main" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginStart="@dimen/margin_smallxx" android:layout_marginTop="@dimen/margin_normalxx" android:layout_marginEnd="@dimen/margin_smallxx" android:orientation="vertical"> shadowStyle如下。 <style name="shadowStyle" parent="@android:style/TextAppearance"> <item name="android:layout_width">match_parent</item> <item name="android:layout_height">match_parent</item> <item name="android:text"></item> <item name="android:background">@drawable/myrect</item> <item name="android:outlineSpotShadowColor">@color/shadow_color</item> </style> 和myrect.xml形状如下。 <?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle"> <solid android:color="#FFFFFF" /> <corners android:radius="20dp" /> </shape> 当我添加此内容时,下面的所有视图都会被隐藏,这很奇怪。 应用程序截图如下。 我将 shadow_color 表示为 #FF00FF 仅用于测试目的。 知道如何使其正确吗?我是不是错过了什么... 以下是我根据mãĴď评论所做的事情 <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" xmlns:app="http://schemas.android.com/apk/res-auto" android:background="@color/white"> <androidx.cardview.widget.CardView android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginStart="@dimen/margin_smallxx" android:layout_marginTop="@dimen/margin_normalxx" android:layout_marginEnd="@dimen/margin_smallxx" app:cardCornerRadius="10dp" app:cardElevation="20dp" android:outlineSpotShadowColor="@color/shadow_color" > <LinearLayout android:id="@+id/ll_main" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical"> ........ </LinearLayout> </CardView> </RelativeLayout> 这意味着我们将拥有卡片视图并将整个布局放入其中......


© www.soinside.com 2019 - 2024. All rights reserved.