栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 前沿技术 > 大数据 > 大数据系统

ElasticSearch 学习记录,持续更新中

ElasticSearch 学习记录,持续更新中

1.创建索引

目录

1.创建索引

2.使用_search查询出来的结果字段解释


        因为需要客户端去设置索引的 名称,所以需要使用PUT不要使用POST,关于post和get的详解可以查看RESTful 架构详解 | 菜鸟教程

​
PUT http://localhost:9200/schools/

2.使用_search查询出来的结果字段解释
{
    "took": 36,---表示Elasticsearch执行搜索所用的时间,单位是毫秒。
    "timed_out": false,---用来指示搜索是否超时。
    "_shards": {----指示搜索了多少分片,以及搜索成功和失败的分片的计数。
        "total": 1,
        "successful": 1,
        "skipped": 0,
        "failed": 0
    },
    "hits": {----用来实际搜索结果集。
        "total": {---是包含与搜索条件匹配的文档总数信息的对象。
            "value": 8,----表示总命中计数的值(必须在hits.total.relation上下文中解释)。
            "relation": "eq"----hits.total.value是不确切的命中计数,在这种情况下,当hits.total.relation的值是eq时,hits.total.value的值是准确计数。当hits.total.relation的值是gte时,hits.total.value的值是不准确的。
        },
        "max_score": 1.0,
        "hits": [---是存储搜索结果的实际数组(默认为前10个文档,无法将所有的数据查询出来,如果要查询多条数据需要设置size字段)。
            {
                "_index": "movies",
                "_type": "movie",
                "_id": "bjcDdHwBIy0-N-dXxept",
                "_score": 1.0,
                "_source": {
                    "title": "The Godfather",
                    "director": "Francis Ford Coppola",
                    "year": 1972,
                    "age": 189,
                    "name": "sanba"
                }
            }...
        ]
    }
}
3.ElasticSearch的数据类型

这篇博文对es的数据类型讲解的很清晰Elasticsearch品读—第三章:ES数据类型_sym542569199的博客-CSDN博客_es数据类型

4.ElasticSearch的DSL语法

4.1match是匹配查询,match的operator的属性有and、or,其中and是所有的分词都匹配时才能返回true,但是or是其中一个分词成立就会返回or,这个属性也就是对应的sql的and和or只是分词的量要大于等于查询文本的量。

4.2简单说几个es中内置的分词器

standard  由以下组成
tokenizer:Standard Tokenizer
token filter:Standard Token Filter,Lower Case Token Filter,Stop Token Filter
POST _analyze
{
  "analyzer": "standard",
  "text": "The 2 QUICK Brown-Foxes jumped over the lazy dog's bone."
}

whitespace  空格为分隔符
POST _analyze
{
  "analyzer": "whitespace",
  "text": "The 2 QUICK Brown-Foxes jumped over the lazy dog's bone."
}

POST _analyze
{
  "analyzer": "simple",
  "text": "The 2 QUICK Brown-Foxes jumped over the lazy dog's bone."
}

stop   默认stopwords用_english_ 
POST _analyze
{
  "analyzer": "stop",
  "text": "The 2 QUICK Brown-Foxes jumped over the lazy dog's bone."
}

keyword  不分词的
POST _analyze
{
  "analyzer": "keyword",
  "text": ["The 2 QUICK Brown-Foxes jumped over the lazy dog's bone."]
}

4.3es中的术语(term)就是被es分词器分析后的结果,结果中的每一个词语都是术语(term)

4.4term查询 只可以对keyword等不使用分词的字段

4.5复合查询

4.5.1constant_score :它改变过滤器中每个文档的查询常量分数,默认为1,可以用boost参数修改。

4.5.2

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/327081.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号