美文网首页
ElasticSearch03索引(index)三层含义

ElasticSearch03索引(index)三层含义

作者: 极光火狐狸 | 来源:发表于2017-08-23 11:51 被阅读31次

在elasticsearch中索引(index)有三个层面的含义:

index(名词)

获取一份文档可以通过在浏览器中直接输入url、curl命令或程序es.get()好几种方式去完成。
浏览器: http://192.168.1.132/website/blog/1
curl: curl -XGET http://192.168.1.132/website/blog/1
程序(python):

from elasticsearch import Elasticsearch
from pprint import pprint
es = Elasticsearch(hosts=["192.168.1.132"])
s = es.get(
    index="website",
    doc_type="blog",
    id=1
)
pprint(s)

uri /website/blog/1 中的 /website 就是一个index(名词), 第二级路径/blog是类别, 用于对文档的二级归类.

index(动词)

指的是写入一份文档到一个索引(名词)中,这个行为叫做index(动词)。例如下面这段代码实际上就是将body这个json文档,写入到website的索引(名词)中。

from elasticsearch import Elasticsearch
es = Elasticsearch(hosts=["192.168.1.132"])
es.index(
    index="website",
    doc_type="blog",
    id=1,
    body={
        "title": "My first blog entry",
        "text":  "Just trying this out...",
        "date":  "2014/01/01"
    }
)

Inverted index(倒排索引)

关系型数据库中采用B-tree为某个指定的字段创建索引(该索引与上面两种说法都不一样),从而提高数据检索速度,而elasticsearch采用Inverted index(倒排索引)来达到相同目的。

elasticsearch在默认情况下,为每个字段都做了一个倒排索引。

更多需要参考这里:
倒排索引
精确值VS全文

相关文章

  • ElasticSearch03索引(index)三层含义

    在elasticsearch中索引(index)有三个层面的含义: index(名词) 获取一份文档可以通过在浏览...

  • ElasticSearch初识(二)

    什么是正向索引、什么是倒排索引? 正向索引(forward index),反向索引(inverted index)...

  • 7. Interview-MySQL

    1 MySQL索引类型? 普通索引,index 主键索引,primary 唯一索引,unique index 全文...

  • InnoDB,select会阻塞insert吗?

    InnoDB的索引有两类索引,聚集索引(Clustered Index)与普通索引(Secondary Index...

  • Mysql优化大数据量查询速度--索引IDNEX

    这里以普通索引INDEX为例 创建索引 CREATE INDEX index_name ON table_name...

  • index索引

    是什么 数据库索引,是数据库管理系统中一个排序的数据结构,以协助快速查询、更新数据库表中的数据。索引的实现通常是使...

  • 查找和引用函数CHOOSE

    1.choose函数的含义 根据索引值返回后面对应的值 步骤阅读 A、Index_Num 为 1 到 254 之间...

  • ES(ElasticSearch)索引笔记

    1.索引脚本新增字段: 描述user_info_index_2: 索引名称user_info_index: 索引别...

  • reset_index()

    reset_index()主要用于重置索引 reset_index()重置索引 在获得新的index,原来的ind...

  • Oracle相关操作

    1. 索引 1.1 创建索引 create index index_name on table_name(colu...

网友评论

      本文标题:ElasticSearch03索引(index)三层含义

      本文链接:https://www.haomeiwen.com/subject/vcsddxtx.html