Linnzh / Utils

PHP学习过程
0 stars 0 forks source link

常用 ES 查询 #4

Open Linnzh opened 3 months ago

Linnzh commented 3 months ago

Spider 爬虫

Click to expand ```json { "query": { "bool": { "should": [ { "match_phrase": { "url.path": "robots.txt" } }, { "match_phrase": { "user_agent.original": "Amazon CloudFront" } }, { "match_phrase": { "user_agent.name": "Amazonbot" } }, { "match_phrase": { "user_agent.name": "robot" } }, { "match_phrase": { "user_agent.name": "ImagesiftBot" } }, { "match_phrase": { "user_agent.name": "GPTBot" } }, { "match_phrase": { "user_agent.name": "Googlebot" } }, { "match_phrase": { "user_agent.name": "FacebookBot" } }, { "match_phrase": { "user_agent.name": "Googlebot-Image" } }, { "match_phrase": { "user_agent.name": "AdsBot-Google" } }, { "match_phrase": { "user_agent.name": "BLEXBot" } }, { "match_phrase": { "user_agent.name": "DingTalkBot" } }, { "match_phrase": { "user_agent.name": "DotBot" } }, { "match_phrase": { "user_agent.name": "YandexBot" } }, { "match_phrase": { "user_agent.name": "SemrushBot" } }, { "match_phrase": { "user_agent.name": "Pinterestbot" } }, { "match_phrase": { "user_agent.name": "bingbot" } }, { "match_phrase": { "user_agent.name": "Applebot" } }, { "match_phrase": { "user_agent.name": "Petalbot" } } ] } } } ```

前端资源 Assets

Click to expand ```json { "query": { "bool": { "should": [ { "prefix": { "url.path": "_nuxt/" } }, { "prefix": { "url.path": "common/icon/" } }, { "prefix": { "url.path": "icons/" } } ] } } } ```
Linnzh commented 3 months ago

关键字查询

{
  "query": {
    "bool": {
      "should": [
        {
          "wildcard": {
            "message": "*Q9xYZBrMOY5A1aH6cLxN8SCDjLYggsGo*"
          }
        },
        {
          "wildcard": {
            "message.text": "*Q9xYZBrMOY5A1aH6cLxN8SCDjLYggsGo*"
          }
        }
      ]
    }
  }
}
Linnzh commented 3 months ago

完全匹配查询(SKU为例)

GET magento2_default_catalog_product/_search
{
  "_source": [
    "entity_id",
    "sku",
    "name",
    "description",
    "type_id",
    "has_options",
    "visibility",
    "option_text_brand",
    "url_key",
    "stock.qty"
  ],
  "query": {
    "bool": {
      "must": [
        {
          "match_phrase": {
            "sku.untouched": "FPLXGD15000461"
          }
        }
      ]
    }
  }
}
Linnzh commented 3 months ago

搜索一组SKU

GET magento2_default_catalog_product/_search
{
  "_source": ["sku", "entity_id", "visibility", "name", "qty_ordered", "stock.qty"], 
  "query": {
    "bool": {
      "filter": [
        {
          "terms": {
            "sku.untouched": [
              "LXFP421HFP2201350",
              "ELHKJ0106",
              "HFPS220979",
              "ELFP1910315",
              "ELHD46647822X6",
              "LXFPEHP60980WIN",
              "ECS009361"
            ]
          }
        }
      ]
    }
  }
}

搜索一组ID

GET magento2_default_catalog_product/_search
{
  "query": {
    "bool": {
      "filter": [
        {
          "terms": {
            "entity_id": [
              "33202","57363","60163","62875","80298","52352","75279","73475","19859","37392"
            ]
          }
        }
      ]
    }
  }
}
Linnzh commented 3 months ago

更新(_update)指定文档

POST magento2_default_catalog_product/_update/40062
{
  "doc": {
    "visibility" : "2"
  }
}