添加数据弹性搜索的最佳方法
我正在发布数据,以便以后在弹性搜索中进行搜索。
我是这样发布的:
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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您对
_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.