markdown 搜索和分析数据 - Pluralsight

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了markdown 搜索和分析数据 - Pluralsight相关的知识,希望对你有一定的参考价值。

<!-- elastic, crud -->

Get health

`curl -XGET 'localhost:9200/_cat/health?v'`

Create index

`curl -XPUT 'localhost:9200/products?&pretty'`

Status yellow --> `Don't have replica`

GET All indices:

`curl -XGET 'localhost:9200/_cat/indices?v&pretty'`

Create a document
```
curl -XPUT 'localhost:9200/products/mobiles/1?pretty' -H 'Content-Type: application/json' -d'
{
    "name" : "iPhone 7",
    "camera" : "12MP",
    "storage" : "256GB",
    "display" : "4.7 inch",
    "battery" : "1960 mAh",
    "reviews": [
        "Incredibly happy after having used it for one week",
        "Best iPhone so far",
        "Very expensive, still prefer Android"
    ]
}
'
```

Retrieve Doc:

`curl -XGET 'localhost:9200/products/mobiles/1?pretty'`

Get specified fields only

`curl -XGET 'localhost:9200/products/mobiles/1?pretty&_source=name,reviews'`

Update whole doc:

`Same with doc creation, but must include id in the url`

```
Partial update the doc:
curl -XPOST 'localhost:9200/products/mobiles/1/_update?pretty' -H 'Content-Type: application/json' -d'
{
    "doc" : {
        "name" : "iPhone 7 Plus"
    }
}
'
```
`New field can be included to partial update body`

Update With script

```
curl -XPOST 'localhost:9200/products/shoes/1/_update?pretty' -H 'Content-Type: application/json' -d'
{
    "script": "ctx._source.size -= 1"
}
'
```

Delete doc:

```
curl -XDELETE 'localhost:9200/products/shoes/1?pretty'
```
Query Context: How well does this document match this query?

Filter Context: Does this document match this query clause?

### For Query Context

* Included or not: Determine whether the document should be part of the result
* Relevance score: Calculated for every search term the document maps to
* High score, more relevant: More relevant documents, higher in the search rankings.

### For Filter Context

* Included or not: Yes / No determines whether included in the result
* No scoring
* Exact matches, range queries
* Faster

**Use devtools for queries below:**

Search along the document:

`GET customers/personal/_search?q=wyoming`

Sort from query param (No score as sorted):

`GET customers/personal/_search?q=wyoming&sort=age:desc`

From and size from query param:

`GET customers/_search?q=state:kentucky&from=10&size=2`

### Query from request body

Get all docs with from, sort and size:

```
{
  "from": 5, 
  "size": 3,
  "sort": [
    {
      "age": {
        "order": "desc"
      }
    }
  ], 
  "query": {
    "match_all": {}
  }
}
```

Using _source in query:

```
GET customers/personal/_search
{
  "_source": ["st*", "*n*"], 
  "query": {
    "term": {
      "state": {
        "value": "wyoming"
      }
    }
  }
}
```

```
GET customers/personal/_search
{
  "_source": {
    "includes": ["st*", "*n*"],
    "excludes": ["*der*"]
  }, 
  "query": {
    "term": {
      "state": {
        "value": "wyoming"
      }
    }
  }
}
```

以上是关于markdown 搜索和分析数据 - Pluralsight的主要内容,如果未能解决你的问题,请参考以下文章

markdown 静态PHP7分析与phan和

日志分析工具ELK

markdown 智能代码搜索源代码搜索智能[jetbrains]

实现泰坦尼克号预测源码和分析

vscode中预览markdown文件

OpenSearch 可以轻松摄取搜索可视化和分析数据