Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Elastic zero to hero

Elastic zero to hero

PHPERS Summit 2019 Poznań

K.Skaradziński

September 04, 2019
Tweet

More Decks by K.Skaradziński

Other Decks in Programming

Transcript

  1. SAMPLE RESPONSE { "_index" : "test", "_type" : "_doc", "_id"

    : "H9wYAG0Bjhby-D6cxV_8", "_version" : 1, "result" : "created", "_shards" : { "total" : 2, "successful" : 1, "failed" : 0 }, "_seq_no" : 0, "_primary_term" : 1 }
  2. SAMPLE RESPONSE { "_index" : "test", "_type" : "_doc", "_id"

    : "H9wYAG0Bjhby-D6cxV_8", "_version" : 2, "result" : "updated", "_shards" : { "total" : 2, "successful" : 1, "failed" : 0 }, "_seq_no" : 0, "_primary_term" : 1 }
  3. SAMPLE RESPONSE { "_index" : "test", "_type" : "_doc", "_id"

    : "H9wYAG0Bjhby-D6cxV_8", "_version" : 2, "result" : "deleted", "_shards" : { "total" : 2, "successful" : 1, "failed" : 0 }, "_seq_no" : 0, "_primary_term" : 1 }
  4. While using the _version might seem to work in certain

    cases, I would recommend to never use it for anything else than optimistic locking of updates. In particular, versions do not carry any meaning: they might look like the number of times a document has been modified but it is not always the case (for instance if you create a new document which has the same ID as a document that you just deleted, the version number of the new document will not be 1), and more importantly it is an implementation detail, this behaviour might change in the future. Versioning
  5. BULK curl -X POST "localhost:9200/_bulk" -H 'Content-Type: application/json' -d' {

    "create" : { "_index" : "test", "_id" : "1" } } {“field”: “value”, “field”: “value”} { "delete" : { "_index" : "test", "_id" : "1" } } { "update" : {"_id" : "1", "_index" : "test"} } { "doc" : {"field2" : "value2"} }
  6. CHAR FILTER The character filter has the ability to perform

    addition, removal or replacement actions on the input text given to them.
  7. TOKENIZER A tokenizer receives a stream of characters, breaks it

    up into individual tokens (usually individual words), and outputs a stream of tokens
  8. TOKEN FILTER Token filters can act on the tokens generated

    from the tokenizers and modify, add or remove them
  9. BUILD IN ANALYZERS ‣ standard (default) combination of (standard token

    filter, lowercase and stop token filter) ‣ simple ‣ whitespace ‣ stop ‣ keyword ‣ pattern ‣ language ‣ fingerprint
  10. INVERTED INDEX Token Document 1 Document 2 frontend 1 php

    1 developer 1 1 poznan 1 warszawa 1
  11. MAPPING Mapping is the process of defining how a document,

    and the fields it contains, are stored and indexed. For instance, use mappings to define: ‣ which string fields should be treated as full text fields. ‣ which fields contain numbers, dates, or geolocations. ‣ the format of date values. ‣ custom rules to control the mapping for dynamically added fields.
  12. MAPPING "mappings": { "properties": { "age": { "type": "integer" },

    "email": { "type": "keyword" }, "name": { "type": "text" } } }
  13. DYNAMIC MAPPING TEMPLATES "dynamic_templates": [ { "strings": { "match_mapping_type": "string",

    "mapping": { "type": "text", "analyzer": "whitespace" } } } ]
  14. BASIC QUERIES ‣ Match ‣ Multi_match ‣ Term / terms

    ‣ Range ‣ Wildcard ‣ Query_string ‣ Function_score ‣ Script_score
  15. BOOL QUERIES title = "php developer" AND city = "warszawa"

    { "query": { "must": [ { "term": { "title": { "value": "php developer" } } }, { "term": { "city": { "value": "warszawa" } } } ] } }