添加数据弹性搜索的最佳方法

发布于 2025-02-10 13:33:31 字数 504 浏览 1 评论 0原文

我正在发布数据,以便以后在弹性搜索中进行搜索。

我是这样发布的:

POST https://localhost:9200/superheroes/_doc/27

正文:

{
    "name": "Flash",
    "super_power": "Super Speed"
}

它自动存储在_source对象上...但是我阅读 _source字段本身未索引(因此无法搜索)在线,此应用程序的全部目的是快速搜索按价值...就像我想知道哪些超级英雄具有超级速度,并且在搜索栏上写超级速度。

I am posting data so I can search it later in elastic search.

I am posting it like this:

POST https://localhost:9200/superheroes/_doc/27

body:

{
    "name": "Flash",
    "super_power": "Super Speed"
}

This is automatically stored on a _source object... but I read the _source field itself is not indexed (and thus is not searchable) online, and the entire purpose of this application is quick search by value... like if I wanna know which superheroes have super speed and I write super speed on the search bar.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

旧时浪漫 2025-02-17 13:33:31

您对_source字段是正确的,但是如果您不定义字段的映射,则Elasticsearch会生成默认映射,并使用这些字段的默认参数。您可以阅读有关映射param param 在您的情况下,如果您想搜索字段,则需要成为倒置索引的一部分,并且由 index param param

您可以通过定义自己的映射来覆盖这些参数的值(建议否则Elasticsearch将根据您在字段中索引的第一个数据猜测字段类型)。

希望这有帮助并清除您的疑问,简而言之,如果您没有定义映射,则text默认情况下可以搜索数据。

you are right about the _source field, but if you don't define the mapping for your fields, Elasticsearch generates the default mapping with default param for these fields . You can read more about the mapping param and in your case, if you want field to be searchable it needs to be the part of the inverted index and this is controlled by the index param.

You can override the value of these params by defining your own mapping(recommended otherwise Elasticsearch will guess the field type based on the first data you index in a field).

Hope this helps and clears your doubt, in short if you are not defining your mapping, your text data is searchable by default.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文