Giter VIP home page Giter VIP logo

elasticsearchlearning's Introduction

ElasticsearchLearning

learn Elasticsearch

elasticsearchlearning's People

Contributors

fs1360472174 avatar

Watchers

James Cloos avatar  avatar

elasticsearchlearning's Issues

es 按照时间,7天为区间聚合

问题:
时间范围为8.01-8.30但是后面的时间没有

一开始以为是es查询问题,后来发现是数据问题,过滤字段在8-15后面没有该字段。
导致问题

删除文档

header plugin中不支持删除文档
直接删除了
curl -XDELETE 'localhost:9200/event-index/test/_query?pretty' -d '{"query":{"bool":{"filter":[{"term":{"uniqueId":"1505882147000-7482292-101"}}]}}}'

get started

https://www.ibm.com/developerworks/cn/java/j-use-elasticsearch-java-apps/
Relational DB -> Databases -> Tables -> Rows -> Columns
Elasticsearch -> Indices -> Types -> Documents -> Fields

  1. install elastic search

  2. install git shell for curl

  3. 创建一个索引
    curl -XPUT "127.0.0.1:9200/test/"

  4. 插入一个文档

     ` curl -XPUT  "127.0.0.1:9200/test/user/1" -d  '{"name": "name1","id": "1","address": "hanghzou"}'`
    
  5. 查询 文档

      curl -XGET  "127.0.0.1:9200/test/user/1"
{"_index":"test","_type":"user","_id":"1","_version":1,"found":true,"_source":{"name": "name1","id": "1","address": "hanghzou"}}

  1. 搜索

·curl -XGET "127.0.0.1:9200/test/user/_search?q=user:'name'"

  1. json 查询DSL

{
“query”: {
"match" : {
}
}
}

为什么在REST API 中

PUT 请求创建index不可以,只能post

No handler found for uri [/info/user/] and method [PUT]

es 翻页

Caused by: QueryPhaseExecutionException[Result window is too large, from + size must be less than or equal to: [10000] but was [10100]. See the scroll api for a more efficient way to request large data sets. This limit can be set by changing the [index.max_result_window] index level parameter.]

es 过滤null值

{
"query": {
"filtered": {
"filter": {
"missing": {
"field": "name"
}
}
}
}
}
不存在name字段的文档

数据更新的方式

  1. 一般元数据的更新有

按时间的去更新
这个可能的一个潜在问题时,更新瞬时量很大的时候,系统会崩溃

按量去更新
更新不及时,

DSL 查询语句

对于结构化查询,需要去查找准确值,这时候需要使用过滤器,
因为过滤器比较快,不用去计算匹配的相关性,而且容易被缓存

  1. term 过滤器(多个准确值是terms)
    处理数字,布尔值,日期,文本
    完全匹配,不进行分词分析。过滤器查询需要包到一个查询结构体中
    SELECT doc from user where age = 20
    {
    "query": {
    "filtered" : {
    "query": {
    "match_all": {}
    },
    "term": {
    "age": 20
    }
    }
    }
    }
    match_all是默认行为,可以省略掉
    执行filtered查询时,filter会比query早执行,结果字节集会被传给query来跳过已经被排除的文档。

这边的准确值含义和SQL中的意义还是不同,对于String类型的字段,它表示的还是
字符串匹配,是including而不是equal 所以通常查询过程中还是需要其他的字段匹配
2. bool联合查询: must,should,must_not

过滤顺序
https://es.xiaoleilu.com/080_Structured_Search/45_filter_order.html

elastic search 相关结构名词

  • 类型(Type)相当于数据库中的table概念,

  • mapping是针对 Type 的。同一个索引里可以包含多个 Type。
    Mapping 相当于数据库中的schema,用来约束字段的类型,不过 Elasticsearch 的 mapping 可以自动根据数据创建。

  • Allocation 分配

将分片分配给某个节点的过程,包括分配主分片或者副本

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.